이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma warning(disable:4996)
#include<stdio.h>
#include<algorithm>
using namespace std;
struct point{
int a, b;
bool operator <(const point &p)const{
return b < p.b;
}
}w[200010];
int n, m, D[200010];
int main()
{
int i;
scanf("%d%d", &n, &m);
for (i = 0; i < m; i++){
scanf("%d%d", &w[i].a, &w[i].b);
}
sort(w, w + m);
for (i = 2; i <= n; i++)D[i] = -1;
for (i = 0; i < m; i++){
if (D[w[i].a] != -1){
if (D[w[i].b] == -1 || D[w[i].b] > D[w[i].a] + 1)D[w[i].b] = D[w[i].a] + 1;
}
}
printf("%d\n", D[n]);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |