#include "highway.h"
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pb push_back
#define REP(i,n) for(int i = 0; i < n; i ++)
#define FOR(i,a,b) for(int i = a; i < b; i ++)
#define pii pair<int,int>
#define F first
#define S second
const int MAXN = 200005;
int n,m,S,T;
long long path;
vector<pii> adj[MAXN];
int vis[MAXN];
void find_pair(int N, vi U, vi V, int A, int B) {
n = N;
m = U.size();
REP(i,m){
adj[U[i]].pb({V[i],i});
adj[V[i]].pb({U[i],i});
}
vi w(m,0);
path = ask(w);
int l = 0,r = m-1,mid;
while(l < r){
mid = (l+r)/2;
FOR(i,l,mid+1) w[i] = 1;
if(ask(w) == path) l = mid+1;
else{
FOR(i,l,mid+1) w[i] = 0;
r = mid;
}
}
vector<pii> v1,v2;
queue<pii> q;
q.push({U[l],-1});
vis[U[l]] = 1;
q.push({V[l],-1});
vis[V[l]] = 2;
while(!q.empty()){
pii u = q.front();
q.pop();
// cout << u.F << " " << u.S << " " << vis[u.F] << endl;
if(vis[u.F] == 1) v1.pb(u);
else v2.pb(u);
for(auto v:adj[u.F]){
if(!vis[v.F]){
vis[v.F] = vis[u.F];
q.push(v);
}
}
}
int low = 0,high = v1.size()-1;
while(low < high){
mid = (low+high)/2;
REP(i,m) w[i] = 1;
w[l] = 0;
FOR(i,1,(int)v2.size()) w[v2[i].S] = 0;
FOR(i,1,mid+1) w[v1[i].S] = 0;
if(ask(w) == path) high = mid;
else low = mid+1;
}
S = v1[low].F;
// cout << "S::: " << S << "\n";
low = 0,high = v2.size()-1;
while(low < high){
mid = (low+high)/2;
REP(i,m) w[i] = 1;
w[l] = 0;
FOR(i,1,(int)v1.size()) w[v1[i].S] = 0;
FOR(i,1,mid+1) w[v2[i].S] = 0;
if(ask(w) == path) high = mid;
else low = mid+1;
}
T = v2[low].F;
// cout << "T::: " << T << "\n";
answer(S,T);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4992 KB |
Output is correct |
2 |
Correct |
4 ms |
5132 KB |
Output is correct |
3 |
Correct |
4 ms |
5076 KB |
Output is correct |
4 |
Correct |
4 ms |
4992 KB |
Output is correct |
5 |
Correct |
4 ms |
4992 KB |
Output is correct |
6 |
Correct |
4 ms |
4992 KB |
Output is correct |
7 |
Correct |
4 ms |
4992 KB |
Output is correct |
8 |
Correct |
4 ms |
4992 KB |
Output is correct |
9 |
Correct |
4 ms |
4992 KB |
Output is correct |
10 |
Correct |
4 ms |
4992 KB |
Output is correct |
11 |
Correct |
4 ms |
4992 KB |
Output is correct |
12 |
Correct |
4 ms |
5024 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
5120 KB |
Output is correct |
2 |
Correct |
15 ms |
5888 KB |
Output is correct |
3 |
Correct |
145 ms |
11680 KB |
Output is correct |
4 |
Correct |
150 ms |
11772 KB |
Output is correct |
5 |
Correct |
147 ms |
11692 KB |
Output is correct |
6 |
Correct |
145 ms |
11684 KB |
Output is correct |
7 |
Correct |
148 ms |
11812 KB |
Output is correct |
8 |
Correct |
150 ms |
11816 KB |
Output is correct |
9 |
Correct |
145 ms |
11688 KB |
Output is correct |
10 |
Correct |
145 ms |
11684 KB |
Output is correct |
11 |
Correct |
160 ms |
10980 KB |
Output is correct |
12 |
Correct |
157 ms |
11212 KB |
Output is correct |
13 |
Correct |
156 ms |
11120 KB |
Output is correct |
14 |
Correct |
183 ms |
11368 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
5752 KB |
Output is correct |
2 |
Correct |
28 ms |
6392 KB |
Output is correct |
3 |
Correct |
43 ms |
7104 KB |
Output is correct |
4 |
Correct |
124 ms |
10948 KB |
Output is correct |
5 |
Correct |
127 ms |
11052 KB |
Output is correct |
6 |
Correct |
132 ms |
11312 KB |
Output is correct |
7 |
Correct |
122 ms |
11072 KB |
Output is correct |
8 |
Correct |
125 ms |
10940 KB |
Output is correct |
9 |
Correct |
122 ms |
11524 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
5120 KB |
Output is correct |
2 |
Correct |
17 ms |
5760 KB |
Output is correct |
3 |
Correct |
102 ms |
10532 KB |
Output is correct |
4 |
Correct |
144 ms |
11676 KB |
Output is correct |
5 |
Correct |
141 ms |
11768 KB |
Output is correct |
6 |
Correct |
138 ms |
11724 KB |
Output is correct |
7 |
Correct |
139 ms |
11692 KB |
Output is correct |
8 |
Correct |
134 ms |
11648 KB |
Output is correct |
9 |
Correct |
150 ms |
11872 KB |
Output is correct |
10 |
Correct |
150 ms |
11804 KB |
Output is correct |
11 |
Correct |
153 ms |
11104 KB |
Output is correct |
12 |
Correct |
154 ms |
11280 KB |
Output is correct |
13 |
Correct |
160 ms |
11200 KB |
Output is correct |
14 |
Correct |
158 ms |
11012 KB |
Output is correct |
15 |
Correct |
140 ms |
11820 KB |
Output is correct |
16 |
Correct |
136 ms |
11704 KB |
Output is correct |
17 |
Correct |
159 ms |
11364 KB |
Output is correct |
18 |
Correct |
156 ms |
11144 KB |
Output is correct |
19 |
Correct |
139 ms |
11772 KB |
Output is correct |
20 |
Correct |
152 ms |
11108 KB |
Output is correct |
21 |
Correct |
120 ms |
12928 KB |
Output is correct |
22 |
Correct |
121 ms |
12904 KB |
Output is correct |
23 |
Correct |
135 ms |
12124 KB |
Output is correct |
24 |
Correct |
145 ms |
12264 KB |
Output is correct |
25 |
Correct |
154 ms |
11272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
5752 KB |
Output is correct |
2 |
Correct |
18 ms |
5888 KB |
Output is correct |
3 |
Correct |
177 ms |
12124 KB |
Output is correct |
4 |
Correct |
199 ms |
12884 KB |
Output is correct |
5 |
Correct |
214 ms |
13788 KB |
Output is correct |
6 |
Correct |
231 ms |
13568 KB |
Output is correct |
7 |
Correct |
220 ms |
13444 KB |
Output is correct |
8 |
Correct |
232 ms |
13448 KB |
Output is correct |
9 |
Correct |
166 ms |
11388 KB |
Output is correct |
10 |
Correct |
170 ms |
11704 KB |
Output is correct |
11 |
Correct |
182 ms |
12204 KB |
Output is correct |
12 |
Correct |
227 ms |
13104 KB |
Output is correct |
13 |
Correct |
230 ms |
13276 KB |
Output is correct |
14 |
Correct |
238 ms |
13448 KB |
Output is correct |
15 |
Correct |
217 ms |
13656 KB |
Output is correct |
16 |
Correct |
188 ms |
12264 KB |
Output is correct |
17 |
Correct |
143 ms |
12644 KB |
Output is correct |
18 |
Correct |
140 ms |
12876 KB |
Output is correct |
19 |
Correct |
138 ms |
12764 KB |
Output is correct |
20 |
Correct |
138 ms |
12712 KB |
Output is correct |
21 |
Correct |
211 ms |
13656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
5760 KB |
Output is correct |
2 |
Correct |
25 ms |
5880 KB |
Output is correct |
3 |
Correct |
230 ms |
11944 KB |
Output is correct |
4 |
Correct |
182 ms |
12272 KB |
Output is correct |
5 |
Correct |
196 ms |
12588 KB |
Output is correct |
6 |
Correct |
304 ms |
13428 KB |
Output is correct |
7 |
Correct |
214 ms |
12100 KB |
Output is correct |
8 |
Correct |
220 ms |
12380 KB |
Output is correct |
9 |
Correct |
240 ms |
12412 KB |
Output is correct |
10 |
Correct |
299 ms |
13308 KB |
Output is correct |
11 |
Correct |
293 ms |
13588 KB |
Output is correct |
12 |
Correct |
295 ms |
13404 KB |
Output is correct |
13 |
Correct |
233 ms |
12260 KB |
Output is correct |
14 |
Correct |
169 ms |
11704 KB |
Output is correct |
15 |
Correct |
239 ms |
12276 KB |
Output is correct |
16 |
Correct |
164 ms |
11692 KB |
Output is correct |
17 |
Correct |
174 ms |
12220 KB |
Output is correct |
18 |
Correct |
173 ms |
11840 KB |
Output is correct |
19 |
Correct |
210 ms |
12960 KB |
Output is correct |
20 |
Correct |
289 ms |
13564 KB |
Output is correct |
21 |
Correct |
298 ms |
13384 KB |
Output is correct |
22 |
Correct |
224 ms |
13396 KB |
Output is correct |
23 |
Correct |
229 ms |
13392 KB |
Output is correct |
24 |
Correct |
239 ms |
13344 KB |
Output is correct |
25 |
Correct |
225 ms |
13852 KB |
Output is correct |
26 |
Correct |
222 ms |
13780 KB |
Output is correct |
27 |
Correct |
143 ms |
12716 KB |
Output is correct |
28 |
Correct |
136 ms |
12652 KB |
Output is correct |
29 |
Correct |
131 ms |
12896 KB |
Output is correct |
30 |
Correct |
132 ms |
12516 KB |
Output is correct |
31 |
Correct |
149 ms |
12836 KB |
Output is correct |
32 |
Correct |
177 ms |
12708 KB |
Output is correct |
33 |
Correct |
165 ms |
12964 KB |
Output is correct |
34 |
Correct |
144 ms |
12712 KB |
Output is correct |
35 |
Correct |
138 ms |
12720 KB |
Output is correct |
36 |
Correct |
135 ms |
12588 KB |
Output is correct |
37 |
Correct |
139 ms |
12964 KB |
Output is correct |
38 |
Correct |
138 ms |
12580 KB |
Output is correct |
39 |
Correct |
297 ms |
13572 KB |
Output is correct |
40 |
Correct |
292 ms |
13548 KB |
Output is correct |
41 |
Correct |
290 ms |
13652 KB |
Output is correct |
42 |
Correct |
232 ms |
13224 KB |
Output is correct |