#include <bits/stdc++.h>
#include "highway.h"
//~ #include "grader.cpp"
using namespace std;
#define ll long long
int n, m;
vector <pair <int, int> > es, g[90001];
ll light;
int dist;
int find(int root, int b){
vector <bool> vis(n);
queue <int> ready;
vector <int> depth(n);
ready.push(root);
vector <int> nodes;
vis[root] = 1;
while(ready.size()){
int node = ready.front();
ready.pop();
nodes.push_back(node);
for(auto &i : g[node]){
if(vis[i.first]) continue;
vis[i.first] = 1;
depth[i.first] = depth[node] + 1;
ready.push(i.first);
}
}
if(b){
while(depth[nodes.back()] != dist){
nodes.pop_back();
}
}
reverse(nodes.begin(), nodes.end());
if(b){
while(depth[nodes.back()] != dist){
nodes.pop_back();
}
}
vis.assign(m, 0);
vector <int> edges;
for(auto &i : nodes){
for(auto &j : g[i]){
if(vis[j.second]) continue;
vis[j.second] = 1;
edges.push_back(j.second);
}
}
int l = 0, r = (int)edges.size() - 1;
while(max(depth[es[edges[r]].first], depth[es[edges[r]].second]) < dist / 2){
r--;
}
while(l <= r){
int mid = (l + r) / 2;
vector <int> check(m);
for(int i = 0 ; i <= mid ; i++){
check[edges[i]] = 1;
}
if(ask(check) != light) r = mid - 1;
else l = mid + 1;
}
auto edge = es[edges[l]];
if(depth[edge.first] > depth[edge.second]) return edge.first;
return edge.second;
}
void find_pair(int N, std::vector<int> u, std::vector<int> v, int a, int b) {
n = N;
m = u.size();
for(int i = 0 ; i < m ; i++){
g[u[i]].push_back(make_pair(v[i], i));
g[v[i]].push_back(make_pair(u[i], i));
es.push_back(make_pair(u[i], v[i]));
}
light = ask(vector <int>(m, 0));
dist = light / a;
int l = 0, r = m - 1;
while(l <= r){
int mid = (l + r) / 2;
vector <int> check(m);
for(int i = 0 ; i <= mid ; i++){
check[i] = 1;
}
if(ask(check) != light) r = mid - 1;
else l = mid + 1;
}
int root = es[l].first;
int s = find(root, 0);
int t = find(s, 1);
answer(s, t);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2432 KB |
Output is correct |
2 |
Correct |
3 ms |
2432 KB |
Output is correct |
3 |
Correct |
2 ms |
2432 KB |
Output is correct |
4 |
Correct |
2 ms |
2432 KB |
Output is correct |
5 |
Correct |
2 ms |
2432 KB |
Output is correct |
6 |
Correct |
2 ms |
2432 KB |
Output is correct |
7 |
Correct |
2 ms |
2432 KB |
Output is correct |
8 |
Correct |
2 ms |
2432 KB |
Output is correct |
9 |
Correct |
2 ms |
2432 KB |
Output is correct |
10 |
Correct |
2 ms |
2432 KB |
Output is correct |
11 |
Correct |
2 ms |
2432 KB |
Output is correct |
12 |
Correct |
2 ms |
2432 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2560 KB |
Output is correct |
2 |
Correct |
14 ms |
3200 KB |
Output is correct |
3 |
Correct |
149 ms |
10016 KB |
Output is correct |
4 |
Correct |
176 ms |
10032 KB |
Output is correct |
5 |
Correct |
148 ms |
10012 KB |
Output is correct |
6 |
Correct |
257 ms |
10024 KB |
Output is correct |
7 |
Correct |
138 ms |
10012 KB |
Output is correct |
8 |
Correct |
150 ms |
10072 KB |
Output is correct |
9 |
Correct |
214 ms |
10024 KB |
Output is correct |
10 |
Correct |
254 ms |
10096 KB |
Output is correct |
11 |
Correct |
157 ms |
9728 KB |
Output is correct |
12 |
Correct |
151 ms |
9796 KB |
Output is correct |
13 |
Correct |
265 ms |
9716 KB |
Output is correct |
14 |
Correct |
250 ms |
9712 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
3200 KB |
Output is correct |
2 |
Correct |
46 ms |
4084 KB |
Output is correct |
3 |
Correct |
34 ms |
4796 KB |
Output is correct |
4 |
Correct |
158 ms |
9728 KB |
Output is correct |
5 |
Correct |
109 ms |
9728 KB |
Output is correct |
6 |
Correct |
218 ms |
9720 KB |
Output is correct |
7 |
Correct |
108 ms |
9732 KB |
Output is correct |
8 |
Correct |
100 ms |
9720 KB |
Output is correct |
9 |
Correct |
107 ms |
9912 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2560 KB |
Output is correct |
2 |
Correct |
18 ms |
3200 KB |
Output is correct |
3 |
Correct |
221 ms |
8660 KB |
Output is correct |
4 |
Correct |
145 ms |
10084 KB |
Output is correct |
5 |
Correct |
254 ms |
10012 KB |
Output is correct |
6 |
Correct |
145 ms |
10004 KB |
Output is correct |
7 |
Correct |
137 ms |
10012 KB |
Output is correct |
8 |
Correct |
138 ms |
10016 KB |
Output is correct |
9 |
Correct |
223 ms |
10016 KB |
Output is correct |
10 |
Correct |
263 ms |
10020 KB |
Output is correct |
11 |
Correct |
150 ms |
9828 KB |
Output is correct |
12 |
Correct |
146 ms |
9724 KB |
Output is correct |
13 |
Correct |
135 ms |
9716 KB |
Output is correct |
14 |
Correct |
272 ms |
9728 KB |
Output is correct |
15 |
Correct |
140 ms |
10100 KB |
Output is correct |
16 |
Correct |
256 ms |
10024 KB |
Output is correct |
17 |
Correct |
146 ms |
9724 KB |
Output is correct |
18 |
Correct |
152 ms |
9932 KB |
Output is correct |
19 |
Correct |
143 ms |
10028 KB |
Output is correct |
20 |
Correct |
138 ms |
9728 KB |
Output is correct |
21 |
Correct |
122 ms |
10112 KB |
Output is correct |
22 |
Correct |
123 ms |
10200 KB |
Output is correct |
23 |
Correct |
235 ms |
10300 KB |
Output is correct |
24 |
Correct |
244 ms |
9820 KB |
Output is correct |
25 |
Correct |
212 ms |
9572 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
3448 KB |
Output is correct |
2 |
Correct |
17 ms |
3320 KB |
Output is correct |
3 |
Correct |
280 ms |
10284 KB |
Output is correct |
4 |
Correct |
333 ms |
10668 KB |
Output is correct |
5 |
Correct |
207 ms |
12196 KB |
Output is correct |
6 |
Correct |
201 ms |
12192 KB |
Output is correct |
7 |
Correct |
208 ms |
12220 KB |
Output is correct |
8 |
Correct |
207 ms |
12200 KB |
Output is correct |
9 |
Correct |
259 ms |
10332 KB |
Output is correct |
10 |
Correct |
200 ms |
11048 KB |
Output is correct |
11 |
Correct |
195 ms |
11392 KB |
Output is correct |
12 |
Correct |
345 ms |
11940 KB |
Output is correct |
13 |
Correct |
384 ms |
12088 KB |
Output is correct |
14 |
Correct |
349 ms |
12412 KB |
Output is correct |
15 |
Correct |
218 ms |
12396 KB |
Output is correct |
16 |
Correct |
320 ms |
11260 KB |
Output is correct |
17 |
Correct |
240 ms |
10200 KB |
Output is correct |
18 |
Correct |
264 ms |
10420 KB |
Output is correct |
19 |
Correct |
191 ms |
10204 KB |
Output is correct |
20 |
Correct |
149 ms |
10324 KB |
Output is correct |
21 |
Correct |
203 ms |
12232 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
3320 KB |
Output is correct |
2 |
Correct |
44 ms |
3488 KB |
Output is correct |
3 |
Correct |
188 ms |
10336 KB |
Output is correct |
4 |
Correct |
265 ms |
10556 KB |
Output is correct |
5 |
Correct |
324 ms |
11044 KB |
Output is correct |
6 |
Correct |
382 ms |
12280 KB |
Output is correct |
7 |
Correct |
173 ms |
10336 KB |
Output is correct |
8 |
Correct |
175 ms |
10528 KB |
Output is correct |
9 |
Correct |
333 ms |
10572 KB |
Output is correct |
10 |
Partially correct |
218 ms |
12288 KB |
Output is partially correct |
11 |
Correct |
364 ms |
12224 KB |
Output is correct |
12 |
Partially correct |
235 ms |
12332 KB |
Output is partially correct |
13 |
Partially correct |
319 ms |
11240 KB |
Output is partially correct |
14 |
Partially correct |
194 ms |
11048 KB |
Output is partially correct |
15 |
Partially correct |
265 ms |
11220 KB |
Output is partially correct |
16 |
Partially correct |
175 ms |
11044 KB |
Output is partially correct |
17 |
Partially correct |
168 ms |
11224 KB |
Output is partially correct |
18 |
Partially correct |
189 ms |
10968 KB |
Output is partially correct |
19 |
Partially correct |
290 ms |
11864 KB |
Output is partially correct |
20 |
Correct |
353 ms |
12128 KB |
Output is correct |
21 |
Partially correct |
219 ms |
12472 KB |
Output is partially correct |
22 |
Correct |
365 ms |
12612 KB |
Output is correct |
23 |
Correct |
216 ms |
12480 KB |
Output is correct |
24 |
Correct |
205 ms |
12420 KB |
Output is correct |
25 |
Partially correct |
220 ms |
12388 KB |
Output is partially correct |
26 |
Partially correct |
226 ms |
12396 KB |
Output is partially correct |
27 |
Partially correct |
140 ms |
10320 KB |
Output is partially correct |
28 |
Partially correct |
254 ms |
10276 KB |
Output is partially correct |
29 |
Partially correct |
152 ms |
10448 KB |
Output is partially correct |
30 |
Partially correct |
217 ms |
10248 KB |
Output is partially correct |
31 |
Correct |
259 ms |
10428 KB |
Output is correct |
32 |
Correct |
134 ms |
10140 KB |
Output is correct |
33 |
Partially correct |
151 ms |
10660 KB |
Output is partially correct |
34 |
Partially correct |
148 ms |
10204 KB |
Output is partially correct |
35 |
Correct |
274 ms |
10208 KB |
Output is correct |
36 |
Partially correct |
253 ms |
10108 KB |
Output is partially correct |
37 |
Partially correct |
222 ms |
10436 KB |
Output is partially correct |
38 |
Partially correct |
141 ms |
10272 KB |
Output is partially correct |
39 |
Correct |
229 ms |
12232 KB |
Output is correct |
40 |
Correct |
208 ms |
12228 KB |
Output is correct |
41 |
Correct |
195 ms |
12224 KB |
Output is correct |
42 |
Correct |
333 ms |
12284 KB |
Output is correct |