3 条题解
-
312107张凌睿 (202112107张凌睿) LV 10 @ 2022-07-25 11:54:03
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cctype>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#define INF 2147483647
#define LL long long
#define ULL unsigned long long
#define MAXN 10005
using namespace std;
inline int read()
{
char ch=getchar();
int x=0,f=1;
while(!isdigit(ch))
{
if(ch=='-') f=-1;
ch=getchar();
}
while(isdigit(ch))
{
x=x*10+ch-'0';
ch=getchar();
}
return x*f;
}
struct Edge{
int v,w;
Edge(int v=0,int w=0):v(v),w(w){}};
struct Node{
int id;
LL d;
Node(int id=0,LL d=0):id(id),d(d){}
bool operator <(const Node& n1)const{
return d>n1.d;
}
};
vector<Edge> adj[500005];
priority_queue<Node> q;
int n,m,s;
LL d[MAXN];
bool vis[MAXN];
void dijkstra(int st)
{
for(int i=1;i<=n;i++) d[i]=INF;
d[st]=0;
int u=0,v=0,w=0;
q.push(Node(st,0));
while(!q.empty())
{
u=q.top().id;
q.pop();
if(vis[u]) continue;
vis[u]=1;int len=adj[u].size();
for(int i=0;i<len;i++)
{
v=adj[u][i].v;
w=adj[u][i].w;
if(d[u]+w<d[v])
{
d[v]=d[u]+w;
q.push(Node(v,d[v]));
}
}
}
}
int aa,bb;
int main()
{
aa=read();
bb=read();
n=3;
adj[1].push_back(Edge(2,aa));
adj[2].push_back(Edge(3,bb));
dijkstra(1);
printf("%lld",d[3]);
return 0;
}
//不适合高精度:)。靓仔,给个赞呗! -
02021-10-29 20:21:17@
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
cout<<a+b;
return 0;
}
//吃个桃桃 -
-12021-10-29 20:21:19@
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
cout<<a+b;
return 0;
}
//吃个桃桃
- 1
信息
- ID
- 2310
- 难度
- 1
- 分类
- (无)
- 标签
- 递交数
- 257
- 已通过
- 195
- 通过率
- 76%
- 被复制
- 3
- 上传者