Submission #9161

# Submission time Handle Problem Language Result Execution time Memory
9161 2014-09-28T04:13:29 Z kcm1700 Your life (kriii2_Y) C++14
4 / 4
76 ms 7116 KB
#include <cstdio>
#include <algorithm>

using namespace std;

int n,m;
int dt[100303];
vector<int> jump[100330];

int main(){
  scanf("%d%d",&n,&m);
  for(int i = 0; i < m; i++) {
    int x,y;
    scanf("%d%d",&x,&y);
    jump[x].push_back(y);
  }
  dt[1] = 1;
  for(int i = 1; i <= n; i++) {
    if (dt[i] == 0) continue;
    for(auto v : jump[i]) {
      if (dt[v] == 0 || dt[v] > dt[i] + 1){
        dt[v] = dt[i] + 1;
      }
    }
  }
  printf("%d\n",dt[n]-1);
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3948 KB Output is correct
2 Correct 0 ms 3948 KB Output is correct
3 Correct 0 ms 3948 KB Output is correct
4 Correct 0 ms 3948 KB Output is correct
5 Correct 0 ms 3948 KB Output is correct
6 Correct 0 ms 3948 KB Output is correct
7 Correct 0 ms 3948 KB Output is correct
8 Correct 0 ms 3948 KB Output is correct
9 Correct 0 ms 3948 KB Output is correct
10 Correct 20 ms 4484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3948 KB Output is correct
2 Correct 40 ms 6984 KB Output is correct
3 Correct 48 ms 6984 KB Output is correct
4 Correct 48 ms 6984 KB Output is correct
5 Correct 52 ms 6984 KB Output is correct
6 Correct 32 ms 6984 KB Output is correct
7 Correct 36 ms 6984 KB Output is correct
8 Correct 76 ms 7116 KB Output is correct
9 Correct 44 ms 6984 KB Output is correct
10 Correct 72 ms 6720 KB Output is correct