# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
885883 |
2023-12-10T23:46:06 Z |
bobbilyking |
Race (IOI11_race) |
C++17 |
|
211 ms |
104612 KB |
#include "race.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
#define NN 200010
#define F(i, l, r) for (ll i = (l); i < (r); ++i)
vector<pl> adj[NN];
struct mp {
ll plen = 0, pwe = 0;
map<ll, ll> mp; // maps weight -> lens, lazy updates and shit
void insert(ll k, ll w) {
if (!mp.count(k-pwe)) mp[k-pwe] = w - plen;
else mp[k-pwe] = min(w - plen, mp[k-pwe]);
}
ll query(ll k) {
if (!mp.count(k-pwe)) return 1e9;
return mp[k-pwe] + plen;
}
vector<pl> getall() const {
vector<pl> res;
for (const auto &[k, v]: mp) res.emplace_back(k + pwe, v + plen);
return res;
}
};
ll ans, k;
mp dfs(ll i, ll p) {
mp cur;
for (auto [x, w]: adj[i]) if (x-p) {
auto child = dfs(x, i);
child.plen++; child.pwe+=w;
if (cur.mp.size() < child.mp.size()) swap(cur, child);
for (const auto [cpath, clen]: child.getall()) {
ans = min(ans, cur.query(k - cpath) + clen);
cur.insert(cpath, clen);
}
}
ans = min(ans, cur.query(k));
cur.insert(0, 0);
return cur;
}
int best_path(int N, int K, int H[][2], int L[])
{
F(i, 0, N-1) {
adj[H[i][0]].emplace_back(H[i][1], L[i]);
adj[H[i][1]].emplace_back(H[i][0], L[i]);
}
ans = N;
k = K;
dfs(0, 0);
return ans == N ? -1: ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
8796 KB |
Output is correct |
2 |
Correct |
2 ms |
8796 KB |
Output is correct |
3 |
Correct |
2 ms |
8796 KB |
Output is correct |
4 |
Correct |
1 ms |
8796 KB |
Output is correct |
5 |
Correct |
2 ms |
8796 KB |
Output is correct |
6 |
Correct |
1 ms |
8796 KB |
Output is correct |
7 |
Correct |
1 ms |
8796 KB |
Output is correct |
8 |
Correct |
2 ms |
8796 KB |
Output is correct |
9 |
Correct |
1 ms |
8796 KB |
Output is correct |
10 |
Correct |
1 ms |
8796 KB |
Output is correct |
11 |
Correct |
1 ms |
8628 KB |
Output is correct |
12 |
Correct |
2 ms |
8796 KB |
Output is correct |
13 |
Correct |
1 ms |
8796 KB |
Output is correct |
14 |
Correct |
1 ms |
8796 KB |
Output is correct |
15 |
Correct |
2 ms |
8796 KB |
Output is correct |
16 |
Correct |
2 ms |
8796 KB |
Output is correct |
17 |
Correct |
1 ms |
8796 KB |
Output is correct |
18 |
Correct |
2 ms |
8796 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
8796 KB |
Output is correct |
2 |
Correct |
2 ms |
8796 KB |
Output is correct |
3 |
Correct |
2 ms |
8796 KB |
Output is correct |
4 |
Correct |
1 ms |
8796 KB |
Output is correct |
5 |
Correct |
2 ms |
8796 KB |
Output is correct |
6 |
Correct |
1 ms |
8796 KB |
Output is correct |
7 |
Correct |
1 ms |
8796 KB |
Output is correct |
8 |
Correct |
2 ms |
8796 KB |
Output is correct |
9 |
Correct |
1 ms |
8796 KB |
Output is correct |
10 |
Correct |
1 ms |
8796 KB |
Output is correct |
11 |
Correct |
1 ms |
8628 KB |
Output is correct |
12 |
Correct |
2 ms |
8796 KB |
Output is correct |
13 |
Correct |
1 ms |
8796 KB |
Output is correct |
14 |
Correct |
1 ms |
8796 KB |
Output is correct |
15 |
Correct |
2 ms |
8796 KB |
Output is correct |
16 |
Correct |
2 ms |
8796 KB |
Output is correct |
17 |
Correct |
1 ms |
8796 KB |
Output is correct |
18 |
Correct |
2 ms |
8796 KB |
Output is correct |
19 |
Correct |
1 ms |
8536 KB |
Output is correct |
20 |
Correct |
2 ms |
8792 KB |
Output is correct |
21 |
Correct |
3 ms |
8796 KB |
Output is correct |
22 |
Correct |
3 ms |
8796 KB |
Output is correct |
23 |
Correct |
2 ms |
8796 KB |
Output is correct |
24 |
Correct |
3 ms |
8796 KB |
Output is correct |
25 |
Correct |
3 ms |
8804 KB |
Output is correct |
26 |
Correct |
3 ms |
8792 KB |
Output is correct |
27 |
Correct |
2 ms |
8796 KB |
Output is correct |
28 |
Correct |
2 ms |
8796 KB |
Output is correct |
29 |
Correct |
3 ms |
8796 KB |
Output is correct |
30 |
Correct |
2 ms |
8796 KB |
Output is correct |
31 |
Correct |
2 ms |
8796 KB |
Output is correct |
32 |
Correct |
2 ms |
8796 KB |
Output is correct |
33 |
Correct |
3 ms |
8796 KB |
Output is correct |
34 |
Correct |
2 ms |
8800 KB |
Output is correct |
35 |
Correct |
2 ms |
8792 KB |
Output is correct |
36 |
Correct |
2 ms |
8788 KB |
Output is correct |
37 |
Correct |
2 ms |
8796 KB |
Output is correct |
38 |
Correct |
2 ms |
8792 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
8796 KB |
Output is correct |
2 |
Correct |
2 ms |
8796 KB |
Output is correct |
3 |
Correct |
2 ms |
8796 KB |
Output is correct |
4 |
Correct |
1 ms |
8796 KB |
Output is correct |
5 |
Correct |
2 ms |
8796 KB |
Output is correct |
6 |
Correct |
1 ms |
8796 KB |
Output is correct |
7 |
Correct |
1 ms |
8796 KB |
Output is correct |
8 |
Correct |
2 ms |
8796 KB |
Output is correct |
9 |
Correct |
1 ms |
8796 KB |
Output is correct |
10 |
Correct |
1 ms |
8796 KB |
Output is correct |
11 |
Correct |
1 ms |
8628 KB |
Output is correct |
12 |
Correct |
2 ms |
8796 KB |
Output is correct |
13 |
Correct |
1 ms |
8796 KB |
Output is correct |
14 |
Correct |
1 ms |
8796 KB |
Output is correct |
15 |
Correct |
2 ms |
8796 KB |
Output is correct |
16 |
Correct |
2 ms |
8796 KB |
Output is correct |
17 |
Correct |
1 ms |
8796 KB |
Output is correct |
18 |
Correct |
2 ms |
8796 KB |
Output is correct |
19 |
Correct |
63 ms |
16116 KB |
Output is correct |
20 |
Correct |
62 ms |
17552 KB |
Output is correct |
21 |
Correct |
61 ms |
17500 KB |
Output is correct |
22 |
Correct |
61 ms |
17564 KB |
Output is correct |
23 |
Correct |
91 ms |
18200 KB |
Output is correct |
24 |
Correct |
70 ms |
17204 KB |
Output is correct |
25 |
Correct |
73 ms |
35924 KB |
Output is correct |
26 |
Correct |
67 ms |
51252 KB |
Output is correct |
27 |
Correct |
129 ms |
24864 KB |
Output is correct |
28 |
Correct |
200 ms |
104612 KB |
Output is correct |
29 |
Correct |
197 ms |
100696 KB |
Output is correct |
30 |
Correct |
139 ms |
25568 KB |
Output is correct |
31 |
Correct |
115 ms |
24976 KB |
Output is correct |
32 |
Correct |
145 ms |
25312 KB |
Output is correct |
33 |
Correct |
136 ms |
24652 KB |
Output is correct |
34 |
Correct |
211 ms |
39276 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
8796 KB |
Output is correct |
2 |
Correct |
2 ms |
8796 KB |
Output is correct |
3 |
Correct |
2 ms |
8796 KB |
Output is correct |
4 |
Correct |
1 ms |
8796 KB |
Output is correct |
5 |
Correct |
2 ms |
8796 KB |
Output is correct |
6 |
Correct |
1 ms |
8796 KB |
Output is correct |
7 |
Correct |
1 ms |
8796 KB |
Output is correct |
8 |
Correct |
2 ms |
8796 KB |
Output is correct |
9 |
Correct |
1 ms |
8796 KB |
Output is correct |
10 |
Correct |
1 ms |
8796 KB |
Output is correct |
11 |
Correct |
1 ms |
8628 KB |
Output is correct |
12 |
Correct |
2 ms |
8796 KB |
Output is correct |
13 |
Correct |
1 ms |
8796 KB |
Output is correct |
14 |
Correct |
1 ms |
8796 KB |
Output is correct |
15 |
Correct |
2 ms |
8796 KB |
Output is correct |
16 |
Correct |
2 ms |
8796 KB |
Output is correct |
17 |
Correct |
1 ms |
8796 KB |
Output is correct |
18 |
Correct |
2 ms |
8796 KB |
Output is correct |
19 |
Correct |
1 ms |
8536 KB |
Output is correct |
20 |
Correct |
2 ms |
8792 KB |
Output is correct |
21 |
Correct |
3 ms |
8796 KB |
Output is correct |
22 |
Correct |
3 ms |
8796 KB |
Output is correct |
23 |
Correct |
2 ms |
8796 KB |
Output is correct |
24 |
Correct |
3 ms |
8796 KB |
Output is correct |
25 |
Correct |
3 ms |
8804 KB |
Output is correct |
26 |
Correct |
3 ms |
8792 KB |
Output is correct |
27 |
Correct |
2 ms |
8796 KB |
Output is correct |
28 |
Correct |
2 ms |
8796 KB |
Output is correct |
29 |
Correct |
3 ms |
8796 KB |
Output is correct |
30 |
Correct |
2 ms |
8796 KB |
Output is correct |
31 |
Correct |
2 ms |
8796 KB |
Output is correct |
32 |
Correct |
2 ms |
8796 KB |
Output is correct |
33 |
Correct |
3 ms |
8796 KB |
Output is correct |
34 |
Correct |
2 ms |
8800 KB |
Output is correct |
35 |
Correct |
2 ms |
8792 KB |
Output is correct |
36 |
Correct |
2 ms |
8788 KB |
Output is correct |
37 |
Correct |
2 ms |
8796 KB |
Output is correct |
38 |
Correct |
2 ms |
8792 KB |
Output is correct |
39 |
Correct |
63 ms |
16116 KB |
Output is correct |
40 |
Correct |
62 ms |
17552 KB |
Output is correct |
41 |
Correct |
61 ms |
17500 KB |
Output is correct |
42 |
Correct |
61 ms |
17564 KB |
Output is correct |
43 |
Correct |
91 ms |
18200 KB |
Output is correct |
44 |
Correct |
70 ms |
17204 KB |
Output is correct |
45 |
Correct |
73 ms |
35924 KB |
Output is correct |
46 |
Correct |
67 ms |
51252 KB |
Output is correct |
47 |
Correct |
129 ms |
24864 KB |
Output is correct |
48 |
Correct |
200 ms |
104612 KB |
Output is correct |
49 |
Correct |
197 ms |
100696 KB |
Output is correct |
50 |
Correct |
139 ms |
25568 KB |
Output is correct |
51 |
Correct |
115 ms |
24976 KB |
Output is correct |
52 |
Correct |
145 ms |
25312 KB |
Output is correct |
53 |
Correct |
136 ms |
24652 KB |
Output is correct |
54 |
Correct |
211 ms |
39276 KB |
Output is correct |
55 |
Correct |
11 ms |
9816 KB |
Output is correct |
56 |
Correct |
6 ms |
9308 KB |
Output is correct |
57 |
Incorrect |
42 ms |
17824 KB |
Output isn't correct |
58 |
Halted |
0 ms |
0 KB |
- |