Submission #8390

# Submission time Handle Problem Language Result Execution time Memory
8390 2014-09-13T16:22:22 Z ainta Your life (kriii2_Y) C++
4 / 4
68 ms 3432 KB
#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
1 Correct 0 ms 3432 KB Output is correct
2 Correct 0 ms 3432 KB Output is correct
3 Correct 0 ms 3432 KB Output is correct
4 Correct 0 ms 3432 KB Output is correct
5 Correct 0 ms 3432 KB Output is correct
6 Correct 0 ms 3432 KB Output is correct
7 Correct 0 ms 3432 KB Output is correct
8 Correct 0 ms 3432 KB Output is correct
9 Correct 0 ms 3432 KB Output is correct
10 Correct 24 ms 3432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3432 KB Output is correct
2 Correct 32 ms 3432 KB Output is correct
3 Correct 48 ms 3432 KB Output is correct
4 Correct 44 ms 3432 KB Output is correct
5 Correct 44 ms 3432 KB Output is correct
6 Correct 32 ms 3432 KB Output is correct
7 Correct 32 ms 3432 KB Output is correct
8 Correct 68 ms 3432 KB Output is correct
9 Correct 44 ms 3432 KB Output is correct
10 Correct 68 ms 3432 KB Output is correct