#include "highway.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 3;
ll n, a, b, m, dist;
vector<pair<int, int>> adj[N];
int get_last(int start){
queue<int> q;
q.push(start);
vector<bool> vis(n, false);
vis[start] = true;
vector<pair<int, int>> edges;
while(!q.empty()){
int u = q.front();
q.pop();
for(auto [to, idx]: adj[u]){
if(vis[to]) continue;
edges.push_back({to, idx});
q.push(to);
vis[to] = true;
}
}
int l = 0, r = n - 1;
while(l != r){
int mid = (l + r) >> 1;
vector<int> w(m, 1);
for(int i = 0; i <= mid; ++i)
w[edges[i].second] = 0;
if(ask(w) == dist)
r = mid;
else
l = mid + 1;
}
return edges[l].first;
}
void find_pair(int _n, std::vector<int> u, std::vector<int> v, int _a, int _b) {
m = u.size();
n = _n, a = _a, b = _b;
for(int i = 0; i < m; ++i){
adj[u[i]].push_back({v[i], i});
adj[v[i]].push_back({u[i], i});
}
dist = ask(vector<int>(m, 0));
int l = 0, r = m - 1;
while(l != r){
int mid = (l + r) >> 1;
vector<int> w(m, 1);
for(int i = 0; i <= mid; ++i)
w[i] = 0;
if(ask(w) == dist)
r = mid;
else
l = mid + 1;
}
int x = u[l];
int s = get_last(x);
int t = get_last(s);
answer(s, t);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2640 KB |
Output is correct |
2 |
Correct |
2 ms |
2640 KB |
Output is correct |
3 |
Correct |
2 ms |
2656 KB |
Output is correct |
4 |
Correct |
2 ms |
2640 KB |
Output is correct |
5 |
Correct |
2 ms |
2640 KB |
Output is correct |
6 |
Correct |
2 ms |
2656 KB |
Output is correct |
7 |
Correct |
2 ms |
2640 KB |
Output is correct |
8 |
Correct |
2 ms |
2640 KB |
Output is correct |
9 |
Correct |
2 ms |
2640 KB |
Output is correct |
10 |
Correct |
2 ms |
2640 KB |
Output is correct |
11 |
Correct |
2 ms |
2640 KB |
Output is correct |
12 |
Correct |
2 ms |
2640 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
2648 KB |
Output is correct |
2 |
Correct |
11 ms |
3360 KB |
Output is correct |
3 |
Correct |
123 ms |
9204 KB |
Output is correct |
4 |
Correct |
121 ms |
9328 KB |
Output is correct |
5 |
Correct |
147 ms |
9196 KB |
Output is correct |
6 |
Correct |
116 ms |
9196 KB |
Output is correct |
7 |
Correct |
153 ms |
9316 KB |
Output is correct |
8 |
Correct |
137 ms |
9200 KB |
Output is correct |
9 |
Correct |
134 ms |
9296 KB |
Output is correct |
10 |
Correct |
130 ms |
9228 KB |
Output is correct |
11 |
Correct |
128 ms |
8736 KB |
Output is correct |
12 |
Correct |
124 ms |
8640 KB |
Output is correct |
13 |
Correct |
133 ms |
8616 KB |
Output is correct |
14 |
Correct |
125 ms |
8640 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
3336 KB |
Output is correct |
2 |
Correct |
23 ms |
4012 KB |
Output is correct |
3 |
Correct |
38 ms |
4596 KB |
Output is correct |
4 |
Correct |
88 ms |
8684 KB |
Output is correct |
5 |
Correct |
85 ms |
8628 KB |
Output is correct |
6 |
Correct |
123 ms |
8676 KB |
Output is correct |
7 |
Correct |
108 ms |
8632 KB |
Output is correct |
8 |
Correct |
89 ms |
8628 KB |
Output is correct |
9 |
Correct |
88 ms |
8632 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2640 KB |
Output is correct |
2 |
Correct |
12 ms |
3420 KB |
Output is correct |
3 |
Correct |
100 ms |
7972 KB |
Output is correct |
4 |
Correct |
137 ms |
9208 KB |
Output is correct |
5 |
Correct |
121 ms |
9208 KB |
Output is correct |
6 |
Correct |
136 ms |
9212 KB |
Output is correct |
7 |
Correct |
106 ms |
9204 KB |
Output is correct |
8 |
Correct |
104 ms |
9200 KB |
Output is correct |
9 |
Correct |
117 ms |
9308 KB |
Output is correct |
10 |
Correct |
124 ms |
9212 KB |
Output is correct |
11 |
Correct |
116 ms |
8616 KB |
Output is correct |
12 |
Correct |
125 ms |
8684 KB |
Output is correct |
13 |
Correct |
136 ms |
8700 KB |
Output is correct |
14 |
Correct |
125 ms |
8708 KB |
Output is correct |
15 |
Correct |
118 ms |
9216 KB |
Output is correct |
16 |
Correct |
109 ms |
9208 KB |
Output is correct |
17 |
Correct |
161 ms |
8628 KB |
Output is correct |
18 |
Correct |
114 ms |
8632 KB |
Output is correct |
19 |
Correct |
124 ms |
9208 KB |
Output is correct |
20 |
Correct |
132 ms |
8628 KB |
Output is correct |
21 |
Correct |
85 ms |
9412 KB |
Output is correct |
22 |
Correct |
95 ms |
9552 KB |
Output is correct |
23 |
Correct |
125 ms |
9392 KB |
Output is correct |
24 |
Correct |
123 ms |
9304 KB |
Output is correct |
25 |
Correct |
124 ms |
8736 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
3424 KB |
Output is correct |
2 |
Correct |
11 ms |
3416 KB |
Output is correct |
3 |
Correct |
154 ms |
9644 KB |
Output is correct |
4 |
Correct |
159 ms |
9936 KB |
Output is correct |
5 |
Correct |
207 ms |
10820 KB |
Output is correct |
6 |
Correct |
183 ms |
10948 KB |
Output is correct |
7 |
Correct |
159 ms |
10784 KB |
Output is correct |
8 |
Correct |
179 ms |
10920 KB |
Output is correct |
9 |
Correct |
186 ms |
8572 KB |
Output is correct |
10 |
Correct |
126 ms |
9116 KB |
Output is correct |
11 |
Correct |
202 ms |
9460 KB |
Output is correct |
12 |
Correct |
191 ms |
10584 KB |
Output is correct |
13 |
Correct |
160 ms |
10644 KB |
Output is correct |
14 |
Correct |
161 ms |
10836 KB |
Output is correct |
15 |
Correct |
217 ms |
10840 KB |
Output is correct |
16 |
Correct |
159 ms |
9812 KB |
Output is correct |
17 |
Correct |
118 ms |
9420 KB |
Output is correct |
18 |
Correct |
123 ms |
9624 KB |
Output is correct |
19 |
Correct |
104 ms |
9512 KB |
Output is correct |
20 |
Correct |
109 ms |
9648 KB |
Output is correct |
21 |
Correct |
155 ms |
10888 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
3408 KB |
Output is correct |
2 |
Correct |
22 ms |
3400 KB |
Output is correct |
3 |
Partially correct |
120 ms |
9568 KB |
Output is partially correct |
4 |
Partially correct |
154 ms |
9724 KB |
Output is partially correct |
5 |
Partially correct |
170 ms |
9944 KB |
Output is partially correct |
6 |
Partially correct |
207 ms |
10896 KB |
Output is partially correct |
7 |
Partially correct |
120 ms |
9672 KB |
Output is partially correct |
8 |
Partially correct |
157 ms |
9720 KB |
Output is partially correct |
9 |
Partially correct |
165 ms |
9948 KB |
Output is partially correct |
10 |
Correct |
166 ms |
10912 KB |
Output is correct |
11 |
Partially correct |
216 ms |
10828 KB |
Output is partially correct |
12 |
Partially correct |
203 ms |
10884 KB |
Output is partially correct |
13 |
Correct |
133 ms |
9460 KB |
Output is correct |
14 |
Correct |
137 ms |
9100 KB |
Output is correct |
15 |
Correct |
133 ms |
9516 KB |
Output is correct |
16 |
Correct |
128 ms |
9088 KB |
Output is correct |
17 |
Correct |
138 ms |
9464 KB |
Output is correct |
18 |
Correct |
176 ms |
9152 KB |
Output is correct |
19 |
Correct |
206 ms |
10532 KB |
Output is correct |
20 |
Partially correct |
235 ms |
10684 KB |
Output is partially correct |
21 |
Partially correct |
188 ms |
10844 KB |
Output is partially correct |
22 |
Correct |
181 ms |
10804 KB |
Output is correct |
23 |
Partially correct |
192 ms |
10872 KB |
Output is partially correct |
24 |
Partially correct |
234 ms |
10824 KB |
Output is partially correct |
25 |
Partially correct |
195 ms |
10824 KB |
Output is partially correct |
26 |
Partially correct |
192 ms |
10828 KB |
Output is partially correct |
27 |
Correct |
140 ms |
9552 KB |
Output is correct |
28 |
Correct |
114 ms |
9460 KB |
Output is correct |
29 |
Partially correct |
121 ms |
9680 KB |
Output is partially correct |
30 |
Correct |
104 ms |
9680 KB |
Output is correct |
31 |
Correct |
109 ms |
9516 KB |
Output is correct |
32 |
Correct |
106 ms |
9480 KB |
Output is correct |
33 |
Correct |
115 ms |
9664 KB |
Output is correct |
34 |
Correct |
112 ms |
9608 KB |
Output is correct |
35 |
Partially correct |
102 ms |
9568 KB |
Output is partially correct |
36 |
Correct |
101 ms |
9400 KB |
Output is correct |
37 |
Partially correct |
120 ms |
9616 KB |
Output is partially correct |
38 |
Partially correct |
119 ms |
9572 KB |
Output is partially correct |
39 |
Correct |
168 ms |
10904 KB |
Output is correct |
40 |
Partially correct |
202 ms |
10852 KB |
Output is partially correct |
41 |
Partially correct |
178 ms |
10836 KB |
Output is partially correct |
42 |
Partially correct |
147 ms |
10848 KB |
Output is partially correct |