# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
14026 | gs14004 | Your life (kriii2_Y) | C++14 | 104 ms | 7112 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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]);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |