Redstone红石粉 @ 2017-07-23 14:08:30
为什么 编译不过啊!!! 居然编译失败。。 本地都调试好了的啊。。。
求大神 解释
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#include<iostream>
using namespace std;
int n,m,ans;
long long B;
const int maxm = 10001,maxn = 50005;
int f[maxn],c[maxm],pd[maxn];
long long d[maxn];
int edge,fir[maxn],to[maxm],w[maxm],next[maxm];
queue<int> Q;
void add(int x,int y,int z){
w[++edge] = z; to[edge] = y;
next[edge] = fir[x]; fir[x] = edge;
}
int SPFA(int x){
memset(d,127,sizeof(d));
memset(pd,0,sizeof(pd));
d[1]=0;
Q.push(1); pd[1]=1;
while(!Q.empty()){
int t = Q.front(); Q.pop(); pd[t]=0;
for(int i=fir[t]; i ;i=next[i]){
if( (f[to[i]]<=x)&&(d[t]+w[i]<d[to[i]]) ){
d[to[i]] = d[t] + w[i];
if(pd[to[i]]==0) {Q.push(to[i]); pd[to[i]]==1;}
}
}
}
return B>=d[n];
}
int main(){
scanf("%d%d%d",&n,&m,&B);
int l=0x3f3f3f3f, r=0;
for (int i=1;i<=n;i++){
scanf("%d",&f[i]);
l = min(l,f[i]);
r = max(r,f[i]);
}
for (int i=1;i<=m;i++){
int x,y,z;
scanf("%d%d%d",&x,&y,&z);
add(x,y,z); add(y,x,z);
}
while(l<=r){
int mid=(r-l)/2+l;
cout<<"asd"<<endl;
if(SPFA(mid)){
ans = mid; r = mid-1 ;
}
else l = mid+1;
}
if(ans==0)printf("AFK\n");
else {
int m = -1;
for(int i=1;i<=n;i++) if((f[i]<=ans)&&(f[i]>m)) m=f[i];
printf("%d\n",m);
}
return 0;
}
by yzhang @ 2017-07-23 15:46:17
应该是没有问题的,看看语言有没有选错
by ljc1301 @ 2017-07-23 16:06:05
别用next
by lukelin @ 2017-07-23 20:44:22
有可能你的变量与STL库里的变量重名了