답안 #14026

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
14026 2015-04-25T06:08:59 Z gs14004 Your life (kriii2_Y) C++14
4 / 4
104 ms 7112 KB
#include <cstdio>
#include <vector>
using namespace std;

vector<int> graph[100005];
int dp[100005];

int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    while (m--) {
        int x,y;
        scanf("%d %d",&x,&y);
        graph[y].push_back(x);
    }
    for (int i=2; i<=n; i++) {
        dp[i] = 1e9;
        for (auto &j : graph[i]){
            dp[i] = min(dp[i],dp[j]+1);
        }
    }
    if(dp[n] > n) puts("-1");
    else printf("%d",dp[n]);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3944 KB Output is correct
2 Correct 0 ms 3944 KB Output is correct
3 Correct 0 ms 3944 KB Output is correct
4 Correct 0 ms 3944 KB Output is correct
5 Correct 0 ms 3944 KB Output is correct
6 Correct 0 ms 3944 KB Output is correct
7 Correct 0 ms 3944 KB Output is correct
8 Correct 0 ms 3944 KB Output is correct
9 Correct 0 ms 3944 KB Output is correct
10 Correct 0 ms 4484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3944 KB Output is correct
2 Correct 43 ms 6980 KB Output is correct
3 Correct 78 ms 6980 KB Output is correct
4 Correct 34 ms 6980 KB Output is correct
5 Correct 35 ms 6980 KB Output is correct
6 Correct 39 ms 5528 KB Output is correct
7 Correct 52 ms 5660 KB Output is correct
8 Correct 53 ms 7112 KB Output is correct
9 Correct 51 ms 6980 KB Output is correct
10 Correct 104 ms 6320 KB Output is correct