PTA甲级1111测试点2是什么,本人代码BUG,重点在于测试点或者我代码的BUG。
https://pintia.cn/problem-sets/994805342720868352/exam/problems/994805358663417856
本人代码
#include<bits/stdc++.h>
using namespace std;
int N,M,a,b,c,d,e,box[2][550][550];
vector<int> road[550],p[2];
int ed[550],apr[550],last[550],deep[550];
int findRoad(int st,int en,int i){
memset(ed,0x6f,sizeof ed);
memset(apr,0,sizeof apr);
memset(deep,0,sizeof deep);
for(int z=0;z<N;z++) last[z] = z;
ed[st] = 0;
for(int z=0;z<N;z++){
int key = -1;
for(int z1=0;z1<N;z1++){
if(apr[z1]==0&&(key==-1||ed[key]>ed[z1])){
key = z1;
}
}
if(key==en) break;
apr[key] = 1;
for(int x:road[key]){
int len = ed[key] + box[i][key][x];
if(ed[x]>len || (ed[x]==len&&deep[key]<deep[x])){
ed[x] = len;
last[x] = key;
deep[x] = deep[key] + 1;
}
}
}
while (en!=st){
p[i].push_back(en);
en = last[en];
}
return ed[p[i][0]];
}
int main()
{
cin >> N >> M;
while (M--){
cin >> a >> b >> c >> d >> e;
road[a].push_back(b);
box[0][a][b] = d;
box[1][a][b] = e;
if(c==0){
road[b].push_back(a);
box[0][b][a] = d;
box[1][b][a] = e;
}
}
cin >> a >> b;
int len1 = findRoad(a,b,0);
int len2 = findRoad(a,b,1);
if(p[0]==p[1]){
printf("Distance = %d; Time = %d: %d",len1,len2,a);
for(int z=p[0].size()-1;z>=0;z--) printf(" -> %d",p[0][z]);
}else{
printf("Distance = %d: %d",len1,a);
for(int z=p[0].size()-1;z>=0;z--) printf(" -> %d",p[0][z]);
printf("\nTime = %d: %d",len2,a);
for(int z=p[1].size()-1;z>=0;z--) printf(" -> %d",p[1][z]);
}
return 0;
}