Submission #9317

#TimeUsernameProblemLanguageResultExecution timeMemory
9317moonrabbit2Your life (kriii2_Y)C++98
0 / 4
0 ms1128 KiB
#include <cstdio> int n,m; int link[105][105]; int main() { for(int i=0;i<100;i++) for(int j=0;j<100;j++) link[i][j]=100000; scanf("%d %d",&n,&m); for(int i=0,a,b;i<m;i++){ scanf("%d %d",&a,&b); link[--a][--b]=1; link[b][a]=1; } for(int k=0;k<n;k++){ for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(link[i][j]>link[i][k]+link[k][j]) link[i][j]=link[i][k]+link[k][j]; } } } printf("%d",link[0][n-1]?link[0][n-1]:-1); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...