Submission #68053

# Submission time Handle Problem Language Result Execution time Memory
68053 2018-08-15T20:01:19 Z KieranHorgan Race (IOI11_race) C++17
21 / 100
3000 ms 39084 KB
#pragma GCC optimize("Ofast")
#include "race.h"
#include <bits/stdc++.h>
using namespace std;

vector<pair<pair<int, int>, int>> AdjList[200000];
bitset<400000> done[100];

int best_path(int N, int K, int H[][2], int L[]) {
	for(int i = 0; i+1 < N; i++) {
		AdjList[H[i][0]].push_back({{L[i], H[i][1]}, i*2  });
		AdjList[H[i][1]].push_back({{L[i], H[i][0]}, i*2+1});
	}

	queue<pair<pair<int, int>, pair<int, int>>> q;
	for(int i = 0; i < N; i++)
		q.push(make_pair(make_pair(i, -1), make_pair(0, 0)));
	int u, p, d, s;
	while(!q.empty()) {
		u = q.front().first.first;
		p = q.front().first.second;
		d = q.front().second.first;
		s = q.front().second.second;
		q.pop();
		for(auto v: AdjList[u]) {
			if(v.first.second != p) {
				if(d+v.first.first > K) continue;
				if(d+v.first.first == K)
					return s+1;
				if(K <= 100) {
					if(done[d+v.first.first][v.second])
						continue;
					done[d+v.first.first][v.second] = 1;
				}
				q.push(make_pair(make_pair(v.first.second, u), make_pair(d+v.first.first, s+1)));
			}
		}
	}

	return -1;
}

# Verdict Execution time Memory Grader output
1 Correct 7 ms 5240 KB Output is correct
2 Correct 6 ms 5348 KB Output is correct
3 Correct 8 ms 5348 KB Output is correct
4 Correct 6 ms 5348 KB Output is correct
5 Correct 6 ms 5348 KB Output is correct
6 Correct 7 ms 5484 KB Output is correct
7 Correct 6 ms 5548 KB Output is correct
8 Correct 6 ms 5676 KB Output is correct
9 Correct 7 ms 5676 KB Output is correct
10 Correct 6 ms 5676 KB Output is correct
11 Correct 6 ms 5676 KB Output is correct
12 Correct 8 ms 5676 KB Output is correct
13 Correct 7 ms 5836 KB Output is correct
14 Correct 6 ms 5836 KB Output is correct
15 Correct 8 ms 5836 KB Output is correct
16 Correct 6 ms 5836 KB Output is correct
17 Correct 9 ms 5836 KB Output is correct
18 Correct 6 ms 5836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 5240 KB Output is correct
2 Correct 6 ms 5348 KB Output is correct
3 Correct 8 ms 5348 KB Output is correct
4 Correct 6 ms 5348 KB Output is correct
5 Correct 6 ms 5348 KB Output is correct
6 Correct 7 ms 5484 KB Output is correct
7 Correct 6 ms 5548 KB Output is correct
8 Correct 6 ms 5676 KB Output is correct
9 Correct 7 ms 5676 KB Output is correct
10 Correct 6 ms 5676 KB Output is correct
11 Correct 6 ms 5676 KB Output is correct
12 Correct 8 ms 5676 KB Output is correct
13 Correct 7 ms 5836 KB Output is correct
14 Correct 6 ms 5836 KB Output is correct
15 Correct 8 ms 5836 KB Output is correct
16 Correct 6 ms 5836 KB Output is correct
17 Correct 9 ms 5836 KB Output is correct
18 Correct 6 ms 5836 KB Output is correct
19 Correct 7 ms 5836 KB Output is correct
20 Correct 6 ms 5836 KB Output is correct
21 Correct 27 ms 7396 KB Output is correct
22 Correct 7 ms 7396 KB Output is correct
23 Correct 8 ms 7396 KB Output is correct
24 Correct 9 ms 7396 KB Output is correct
25 Correct 31 ms 7396 KB Output is correct
26 Correct 7 ms 7396 KB Output is correct
27 Correct 7 ms 7396 KB Output is correct
28 Correct 9 ms 7396 KB Output is correct
29 Correct 15 ms 7396 KB Output is correct
30 Correct 10 ms 7396 KB Output is correct
31 Correct 31 ms 7396 KB Output is correct
32 Correct 29 ms 7396 KB Output is correct
33 Correct 20 ms 7396 KB Output is correct
34 Correct 9 ms 7396 KB Output is correct
35 Correct 8 ms 7396 KB Output is correct
36 Correct 8 ms 7396 KB Output is correct
37 Correct 19 ms 7396 KB Output is correct
38 Correct 17 ms 7396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 5240 KB Output is correct
2 Correct 6 ms 5348 KB Output is correct
3 Correct 8 ms 5348 KB Output is correct
4 Correct 6 ms 5348 KB Output is correct
5 Correct 6 ms 5348 KB Output is correct
6 Correct 7 ms 5484 KB Output is correct
7 Correct 6 ms 5548 KB Output is correct
8 Correct 6 ms 5676 KB Output is correct
9 Correct 7 ms 5676 KB Output is correct
10 Correct 6 ms 5676 KB Output is correct
11 Correct 6 ms 5676 KB Output is correct
12 Correct 8 ms 5676 KB Output is correct
13 Correct 7 ms 5836 KB Output is correct
14 Correct 6 ms 5836 KB Output is correct
15 Correct 8 ms 5836 KB Output is correct
16 Correct 6 ms 5836 KB Output is correct
17 Correct 9 ms 5836 KB Output is correct
18 Correct 6 ms 5836 KB Output is correct
19 Correct 492 ms 23636 KB Output is correct
20 Correct 447 ms 23912 KB Output is correct
21 Correct 443 ms 24532 KB Output is correct
22 Correct 601 ms 30112 KB Output is correct
23 Correct 74 ms 30112 KB Output is correct
24 Correct 75 ms 30112 KB Output is correct
25 Correct 1246 ms 30112 KB Output is correct
26 Correct 727 ms 30112 KB Output is correct
27 Correct 648 ms 37288 KB Output is correct
28 Correct 241 ms 37288 KB Output is correct
29 Correct 302 ms 37288 KB Output is correct
30 Correct 525 ms 37288 KB Output is correct
31 Correct 606 ms 37288 KB Output is correct
32 Correct 226 ms 39084 KB Output is correct
33 Execution timed out 3062 ms 39084 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 5240 KB Output is correct
2 Correct 6 ms 5348 KB Output is correct
3 Correct 8 ms 5348 KB Output is correct
4 Correct 6 ms 5348 KB Output is correct
5 Correct 6 ms 5348 KB Output is correct
6 Correct 7 ms 5484 KB Output is correct
7 Correct 6 ms 5548 KB Output is correct
8 Correct 6 ms 5676 KB Output is correct
9 Correct 7 ms 5676 KB Output is correct
10 Correct 6 ms 5676 KB Output is correct
11 Correct 6 ms 5676 KB Output is correct
12 Correct 8 ms 5676 KB Output is correct
13 Correct 7 ms 5836 KB Output is correct
14 Correct 6 ms 5836 KB Output is correct
15 Correct 8 ms 5836 KB Output is correct
16 Correct 6 ms 5836 KB Output is correct
17 Correct 9 ms 5836 KB Output is correct
18 Correct 6 ms 5836 KB Output is correct
19 Correct 7 ms 5836 KB Output is correct
20 Correct 6 ms 5836 KB Output is correct
21 Correct 27 ms 7396 KB Output is correct
22 Correct 7 ms 7396 KB Output is correct
23 Correct 8 ms 7396 KB Output is correct
24 Correct 9 ms 7396 KB Output is correct
25 Correct 31 ms 7396 KB Output is correct
26 Correct 7 ms 7396 KB Output is correct
27 Correct 7 ms 7396 KB Output is correct
28 Correct 9 ms 7396 KB Output is correct
29 Correct 15 ms 7396 KB Output is correct
30 Correct 10 ms 7396 KB Output is correct
31 Correct 31 ms 7396 KB Output is correct
32 Correct 29 ms 7396 KB Output is correct
33 Correct 20 ms 7396 KB Output is correct
34 Correct 9 ms 7396 KB Output is correct
35 Correct 8 ms 7396 KB Output is correct
36 Correct 8 ms 7396 KB Output is correct
37 Correct 19 ms 7396 KB Output is correct
38 Correct 17 ms 7396 KB Output is correct
39 Correct 492 ms 23636 KB Output is correct
40 Correct 447 ms 23912 KB Output is correct
41 Correct 443 ms 24532 KB Output is correct
42 Correct 601 ms 30112 KB Output is correct
43 Correct 74 ms 30112 KB Output is correct
44 Correct 75 ms 30112 KB Output is correct
45 Correct 1246 ms 30112 KB Output is correct
46 Correct 727 ms 30112 KB Output is correct
47 Correct 648 ms 37288 KB Output is correct
48 Correct 241 ms 37288 KB Output is correct
49 Correct 302 ms 37288 KB Output is correct
50 Correct 525 ms 37288 KB Output is correct
51 Correct 606 ms 37288 KB Output is correct
52 Correct 226 ms 39084 KB Output is correct
53 Execution timed out 3062 ms 39084 KB Time limit exceeded
54 Halted 0 ms 0 KB -