Submission #16521

# Submission time Handle Problem Language Result Execution time Memory
16521 2015-08-27T02:26:11 Z hongjun7 Your life (kriii2_Y) C++
4 / 4
75 ms 3036 KB
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
int d[100005];
pair <int, int> p[200005];
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++) {
		scanf("%d%d", &p[i].first, &p[i].second);
	}
	sort(p + 1, p + m + 1);
	for (int i = 1; i <= n; i++) d[i] = -1;
	d[1] = 0;
	for (int i = 1; i <= m; i++) {
		int a = p[i].first, b = p[i].second;
		if (d[a] != -1) if (d[b] == -1 || d[b] > d[a] + 1) d[b] = d[a] + 1;
	}
	printf("%d", d[n]);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3036 KB Output is correct
2 Correct 0 ms 3036 KB Output is correct
3 Correct 0 ms 3036 KB Output is correct
4 Correct 1 ms 3036 KB Output is correct
5 Correct 0 ms 3036 KB Output is correct
6 Correct 0 ms 3036 KB Output is correct
7 Correct 0 ms 3036 KB Output is correct
8 Correct 0 ms 3036 KB Output is correct
9 Correct 0 ms 3036 KB Output is correct
10 Correct 34 ms 3036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3036 KB Output is correct
2 Correct 37 ms 3036 KB Output is correct
3 Correct 62 ms 3036 KB Output is correct
4 Correct 62 ms 3036 KB Output is correct
5 Correct 38 ms 3036 KB Output is correct
6 Correct 48 ms 3036 KB Output is correct
7 Correct 37 ms 3036 KB Output is correct
8 Correct 74 ms 3036 KB Output is correct
9 Correct 57 ms 3036 KB Output is correct
10 Correct 75 ms 3036 KB Output is correct