# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
263093 |
2020-08-13T13:00:28 Z |
Nightlight |
Race (IOI11_race) |
C++14 |
|
583 ms |
103124 KB |
#include "race.h"
#include <bits/stdc++.h>
#define pii pair<long long, int>
using namespace std;
int N;
long long K;
map<long long, int> mp[200005];
vector<pii> adj[200005];
long long dist[200005];
int cnt[200005];
int ans = 1000000000;
void DFS(int u, int p = N) {
int v;
long long w;
mp[u][dist[u]] = cnt[u];
for(pii now : adj[u]) {
v = now.second, w = now.first;
if(v == p) continue;
dist[v] = dist[u] + w;
cnt[v] = cnt[u] + 1;
DFS(v, u);
if(mp[v].size() > mp[u].size()) swap(mp[v], mp[u]);
}
long long jarak;
// cout << u << " -> " << dist[u] << " " << cnt[u] << "\n";
for(pii now : adj[u]) {
v = now.second;
if(v == p) continue;
// cout << v << ":\n";
for(pii it : mp[v]) {
jarak = dist[u] * 2 + K - it.first;
if(mp[u].count(jarak)) {
ans = min(ans, mp[u][jarak] + it.second - cnt[u] * 2);
}
}
for(pii it : mp[v]) {
if(mp[u].count(it.first)) mp[u][it.first] = min(mp[u][it.first], it.second);
else mp[u][it.first] = it.second;
}
}
}
int best_path(int n, int k, int H[][2], int L[]) {
N = n, K = k;
for(int i = 0; i < N - 1; i++) {
adj[H[i][0]].emplace_back(L[i], H[i][1]);
adj[H[i][1]].emplace_back(L[i], H[i][0]);
}
DFS(0);
if(ans == 1000000000) return -1;
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
14464 KB |
Output is correct |
2 |
Correct |
10 ms |
14464 KB |
Output is correct |
3 |
Correct |
11 ms |
14464 KB |
Output is correct |
4 |
Correct |
10 ms |
14592 KB |
Output is correct |
5 |
Correct |
10 ms |
14464 KB |
Output is correct |
6 |
Correct |
11 ms |
14464 KB |
Output is correct |
7 |
Correct |
10 ms |
14464 KB |
Output is correct |
8 |
Correct |
11 ms |
14464 KB |
Output is correct |
9 |
Correct |
10 ms |
14464 KB |
Output is correct |
10 |
Correct |
10 ms |
14464 KB |
Output is correct |
11 |
Correct |
10 ms |
14464 KB |
Output is correct |
12 |
Correct |
10 ms |
14464 KB |
Output is correct |
13 |
Correct |
10 ms |
14464 KB |
Output is correct |
14 |
Correct |
10 ms |
14464 KB |
Output is correct |
15 |
Correct |
10 ms |
14464 KB |
Output is correct |
16 |
Correct |
11 ms |
14464 KB |
Output is correct |
17 |
Correct |
10 ms |
14464 KB |
Output is correct |
18 |
Correct |
11 ms |
14464 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
14464 KB |
Output is correct |
2 |
Correct |
10 ms |
14464 KB |
Output is correct |
3 |
Correct |
11 ms |
14464 KB |
Output is correct |
4 |
Correct |
10 ms |
14592 KB |
Output is correct |
5 |
Correct |
10 ms |
14464 KB |
Output is correct |
6 |
Correct |
11 ms |
14464 KB |
Output is correct |
7 |
Correct |
10 ms |
14464 KB |
Output is correct |
8 |
Correct |
11 ms |
14464 KB |
Output is correct |
9 |
Correct |
10 ms |
14464 KB |
Output is correct |
10 |
Correct |
10 ms |
14464 KB |
Output is correct |
11 |
Correct |
10 ms |
14464 KB |
Output is correct |
12 |
Correct |
10 ms |
14464 KB |
Output is correct |
13 |
Correct |
10 ms |
14464 KB |
Output is correct |
14 |
Correct |
10 ms |
14464 KB |
Output is correct |
15 |
Correct |
10 ms |
14464 KB |
Output is correct |
16 |
Correct |
11 ms |
14464 KB |
Output is correct |
17 |
Correct |
10 ms |
14464 KB |
Output is correct |
18 |
Correct |
11 ms |
14464 KB |
Output is correct |
19 |
Correct |
10 ms |
14464 KB |
Output is correct |
20 |
Correct |
11 ms |
14464 KB |
Output is correct |
21 |
Correct |
12 ms |
14848 KB |
Output is correct |
22 |
Correct |
11 ms |
14720 KB |
Output is correct |
23 |
Correct |
11 ms |
14720 KB |
Output is correct |
24 |
Correct |
11 ms |
14720 KB |
Output is correct |
25 |
Correct |
11 ms |
14848 KB |
Output is correct |
26 |
Correct |
13 ms |
14720 KB |
Output is correct |
27 |
Correct |
11 ms |
14592 KB |
Output is correct |
28 |
Correct |
11 ms |
14720 KB |
Output is correct |
29 |
Correct |
11 ms |
14720 KB |
Output is correct |
30 |
Correct |
11 ms |
14720 KB |
Output is correct |
31 |
Correct |
11 ms |
14720 KB |
Output is correct |
32 |
Correct |
11 ms |
14720 KB |
Output is correct |
33 |
Correct |
12 ms |
14720 KB |
Output is correct |
34 |
Correct |
11 ms |
14720 KB |
Output is correct |
35 |
Correct |
11 ms |
14720 KB |
Output is correct |
36 |
Correct |
11 ms |
14720 KB |
Output is correct |
37 |
Correct |
11 ms |
14720 KB |
Output is correct |
38 |
Correct |
11 ms |
14720 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
14464 KB |
Output is correct |
2 |
Correct |
10 ms |
14464 KB |
Output is correct |
3 |
Correct |
11 ms |
14464 KB |
Output is correct |
4 |
Correct |
10 ms |
14592 KB |
Output is correct |
5 |
Correct |
10 ms |
14464 KB |
Output is correct |
6 |
Correct |
11 ms |
14464 KB |
Output is correct |
7 |
Correct |
10 ms |
14464 KB |
Output is correct |
8 |
Correct |
11 ms |
14464 KB |
Output is correct |
9 |
Correct |
10 ms |
14464 KB |
Output is correct |
10 |
Correct |
10 ms |
14464 KB |
Output is correct |
11 |
Correct |
10 ms |
14464 KB |
Output is correct |
12 |
Correct |
10 ms |
14464 KB |
Output is correct |
13 |
Correct |
10 ms |
14464 KB |
Output is correct |
14 |
Correct |
10 ms |
14464 KB |
Output is correct |
15 |
Correct |
10 ms |
14464 KB |
Output is correct |
16 |
Correct |
11 ms |
14464 KB |
Output is correct |
17 |
Correct |
10 ms |
14464 KB |
Output is correct |
18 |
Correct |
11 ms |
14464 KB |
Output is correct |
19 |
Correct |
168 ms |
37424 KB |
Output is correct |
20 |
Correct |
159 ms |
37244 KB |
Output is correct |
21 |
Correct |
161 ms |
36984 KB |
Output is correct |
22 |
Correct |
172 ms |
36984 KB |
Output is correct |
23 |
Correct |
218 ms |
50040 KB |
Output is correct |
24 |
Correct |
178 ms |
39928 KB |
Output is correct |
25 |
Correct |
162 ms |
37112 KB |
Output is correct |
26 |
Correct |
84 ms |
43384 KB |
Output is correct |
27 |
Correct |
291 ms |
48888 KB |
Output is correct |
28 |
Correct |
408 ms |
84732 KB |
Output is correct |
29 |
Correct |
441 ms |
83388 KB |
Output is correct |
30 |
Correct |
271 ms |
48888 KB |
Output is correct |
31 |
Correct |
268 ms |
48888 KB |
Output is correct |
32 |
Correct |
345 ms |
49016 KB |
Output is correct |
33 |
Correct |
367 ms |
53772 KB |
Output is correct |
34 |
Correct |
457 ms |
85752 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
14464 KB |
Output is correct |
2 |
Correct |
10 ms |
14464 KB |
Output is correct |
3 |
Correct |
11 ms |
14464 KB |
Output is correct |
4 |
Correct |
10 ms |
14592 KB |
Output is correct |
5 |
Correct |
10 ms |
14464 KB |
Output is correct |
6 |
Correct |
11 ms |
14464 KB |
Output is correct |
7 |
Correct |
10 ms |
14464 KB |
Output is correct |
8 |
Correct |
11 ms |
14464 KB |
Output is correct |
9 |
Correct |
10 ms |
14464 KB |
Output is correct |
10 |
Correct |
10 ms |
14464 KB |
Output is correct |
11 |
Correct |
10 ms |
14464 KB |
Output is correct |
12 |
Correct |
10 ms |
14464 KB |
Output is correct |
13 |
Correct |
10 ms |
14464 KB |
Output is correct |
14 |
Correct |
10 ms |
14464 KB |
Output is correct |
15 |
Correct |
10 ms |
14464 KB |
Output is correct |
16 |
Correct |
11 ms |
14464 KB |
Output is correct |
17 |
Correct |
10 ms |
14464 KB |
Output is correct |
18 |
Correct |
11 ms |
14464 KB |
Output is correct |
19 |
Correct |
10 ms |
14464 KB |
Output is correct |
20 |
Correct |
11 ms |
14464 KB |
Output is correct |
21 |
Correct |
12 ms |
14848 KB |
Output is correct |
22 |
Correct |
11 ms |
14720 KB |
Output is correct |
23 |
Correct |
11 ms |
14720 KB |
Output is correct |
24 |
Correct |
11 ms |
14720 KB |
Output is correct |
25 |
Correct |
11 ms |
14848 KB |
Output is correct |
26 |
Correct |
13 ms |
14720 KB |
Output is correct |
27 |
Correct |
11 ms |
14592 KB |
Output is correct |
28 |
Correct |
11 ms |
14720 KB |
Output is correct |
29 |
Correct |
11 ms |
14720 KB |
Output is correct |
30 |
Correct |
11 ms |
14720 KB |
Output is correct |
31 |
Correct |
11 ms |
14720 KB |
Output is correct |
32 |
Correct |
11 ms |
14720 KB |
Output is correct |
33 |
Correct |
12 ms |
14720 KB |
Output is correct |
34 |
Correct |
11 ms |
14720 KB |
Output is correct |
35 |
Correct |
11 ms |
14720 KB |
Output is correct |
36 |
Correct |
11 ms |
14720 KB |
Output is correct |
37 |
Correct |
11 ms |
14720 KB |
Output is correct |
38 |
Correct |
11 ms |
14720 KB |
Output is correct |
39 |
Correct |
168 ms |
37424 KB |
Output is correct |
40 |
Correct |
159 ms |
37244 KB |
Output is correct |
41 |
Correct |
161 ms |
36984 KB |
Output is correct |
42 |
Correct |
172 ms |
36984 KB |
Output is correct |
43 |
Correct |
218 ms |
50040 KB |
Output is correct |
44 |
Correct |
178 ms |
39928 KB |
Output is correct |
45 |
Correct |
162 ms |
37112 KB |
Output is correct |
46 |
Correct |
84 ms |
43384 KB |
Output is correct |
47 |
Correct |
291 ms |
48888 KB |
Output is correct |
48 |
Correct |
408 ms |
84732 KB |
Output is correct |
49 |
Correct |
441 ms |
83388 KB |
Output is correct |
50 |
Correct |
271 ms |
48888 KB |
Output is correct |
51 |
Correct |
268 ms |
48888 KB |
Output is correct |
52 |
Correct |
345 ms |
49016 KB |
Output is correct |
53 |
Correct |
367 ms |
53772 KB |
Output is correct |
54 |
Correct |
457 ms |
85752 KB |
Output is correct |
55 |
Correct |
28 ms |
17664 KB |
Output is correct |
56 |
Correct |
20 ms |
16384 KB |
Output is correct |
57 |
Correct |
105 ms |
34496 KB |
Output is correct |
58 |
Correct |
74 ms |
28776 KB |
Output is correct |
59 |
Correct |
123 ms |
51144 KB |
Output is correct |
60 |
Correct |
373 ms |
86776 KB |
Output is correct |
61 |
Correct |
305 ms |
55416 KB |
Output is correct |
62 |
Correct |
277 ms |
51832 KB |
Output is correct |
63 |
Correct |
328 ms |
51960 KB |
Output is correct |
64 |
Correct |
583 ms |
103124 KB |
Output is correct |
65 |
Correct |
567 ms |
102888 KB |
Output is correct |
66 |
Correct |
412 ms |
83448 KB |
Output is correct |
67 |
Correct |
244 ms |
44808 KB |
Output is correct |
68 |
Correct |
427 ms |
68000 KB |
Output is correct |
69 |
Correct |
437 ms |
68216 KB |
Output is correct |
70 |
Correct |
404 ms |
65528 KB |
Output is correct |