2pow10 @ 2023-10-18 13:55:11
C:\Users\Administrator\Desktop\未命名3.cpp In function 'void dij()': 17 12 C:\Users\Administrator\Desktop\未命名3.cpp [Warning] extended initializer lists only available with -std=c++11 or -std=gnu++11 17 17 C:\Users\Administrator\Desktop\未命名3.cpp [Warning] extended initializer lists only available with -std=c++11 or -std=gnu++11 27 16 C:\Users\Administrator\Desktop\未命名3.cpp [Warning] extended initializer lists only available with -std=c++11 or -std=gnu++11 27 26 C:\Users\Administrator\Desktop\未命名3.cpp [Warning] extended initializer lists only available with -std=c++11 or -std=gnu++11
#include<bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> PII;
const int N=100010,M =N*2;
int h[N],to[M],nxt[M],w[M];
int dis[N];
bool vis[N];
int n,m,s,idx;
inline void add(int u,int v,int c){
nxt[idx] = h[u],to[idx] = v,w[idx] = c,h[u] = idx++;
}
inline void dij(){
memset(dis,0x3f,sizeof dis);
dis[s] = 0;
priority_queue<PII,vector<PII>,greater<PII> > head;
head.push({0,s});
while(head.size()){
int t = head.top().second;
head.pop();
if(vis[t]) continue;
vis[t] = true;
for(int i=h[t];~i;i=nxt[i]){
int j=to[i];
if(dis[j]>dis[t]+w[i]){
dis[j] = dis[t] + w[i];
head.push({dis[j],j});
}
}
}
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
memset(h,-1,sizeof h);
cin >> n >> m >> s;
for(int i=1;i<=m;i++){
int a,b,c;
cin >> a >> b >> c;
add(a,b,c);
}
dij();
for(int i=1;i<=n;i++) cout << dis[i] << " ";
return 0;
}
by operator_ @ 2023-10-18 14:02:34
在我本地可以正确运行
by operator_ @ 2023-10-18 14:04:06
你这个不是报错啊,只是提醒你只有在特定版本才能用这个语法
by gtafics @ 2023-10-18 14:04:47
devc++ 默认使用 c++98 标准编译。
by 2pow10 @ 2023-10-18 15:26:41
好的好的%%%