Submission #9322

# Submission time Handle Problem Language Result Execution time Memory
9322 2014-09-28T05:35:32 Z moonrabbit2 Your life (kriii2_Y) C++
0 / 4
4 ms 5032 KB
#include <cstdio>
int n,m;
int link[1005][1005];
int main()
{
    for(int i=0;i<1000;i++)
        for(int j=0;j<1000;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;
    }
    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]==0?link[0][n-1]:-1);
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5032 KB Output is correct
2 Incorrect 4 ms 5032 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Halted 0 ms 0 KB -