#include "highway.h"
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
vector<pair<int,int>> g[101010];
vector<pair<int,int>> t[2][101010];
void find_pair(int n, std::vector<int> p, std::vector<int> q, int a, int b) {
int m=p.size();
for(int i=0;i<m;i++){
g[p[i]].push_back({q[i],i});
g[q[i]].push_back({p[i],i});
}
int ok=0,ng=m;
vector<int> w(m,0);
int l=ask(w);
while(abs(ok-ng)>1){
int mid=(ok+ng)/2;
vector<int> w2(m);
for(int i=0;i<mid;i++) w2[i]=1;
if(ask(w2)==l) ok=mid;
else ng=mid;
}
int u=p[ok],v=q[ok],uv=ok;
queue<int> qu;
qu.push(u);
qu.push(v);
vector<int> seen(n,0);
vector<int> d(n,0);
vector<int> id(n,-1);
//u,v それぞれ最短路
seen[u]=1;
seen[v]=2;
while(qu.size()){
int nv=qu.front();
qu.pop();
for(auto e:g[nv]){
if(seen[e.fi]==0){
seen[e.fi]=seen[nv];
d[e.fi]=d[nv]+1;
qu.push(e.fi);
id[e.fi]=e.se;
t[seen[e.fi]][e.fi].pb({nv,e.se});
}
}
}
int s=-1,t=-1;
for(int ty=1;ty<=2;ty++){
vector<pair<int,int>> vs;
for(int i=0;i<n;i++){
if(seen[i]==ty) vs.pb({d[i],i});
}
sort(vs.begin(),vs.end());
while(vs.size()>1){
int m2=vs.size();
int mid=m2/2;
vector<int> as(m,1);
as[uv]=0;
for(int i=0;i<n;i++) if(id[i]>=0) as[id[i]]=0;
for(int i=mid;i<m2;i++) as[id[vs[i].se]]=1;
int l2=ask(as);
if(l2==l){
for(int i=mid;i<m2;i++) vs.pop_back();
}
else{
reverse(vs.begin(),vs.end());
for(int i=0;i<mid;i++) vs.pop_back();
reverse(vs.begin(),vs.end());
}
}
if(ty==1) s=vs[0].se;
else t=vs[0].se;
}
answer(s,t);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
7512 KB |
Output is correct |
2 |
Correct |
3 ms |
7512 KB |
Output is correct |
3 |
Correct |
3 ms |
7420 KB |
Output is correct |
4 |
Correct |
3 ms |
7508 KB |
Output is correct |
5 |
Correct |
3 ms |
7512 KB |
Output is correct |
6 |
Correct |
3 ms |
7512 KB |
Output is correct |
7 |
Correct |
3 ms |
7512 KB |
Output is correct |
8 |
Correct |
3 ms |
7512 KB |
Output is correct |
9 |
Correct |
4 ms |
7512 KB |
Output is correct |
10 |
Correct |
3 ms |
7512 KB |
Output is correct |
11 |
Correct |
3 ms |
7512 KB |
Output is correct |
12 |
Correct |
3 ms |
7512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
7512 KB |
Output is correct |
2 |
Correct |
12 ms |
8656 KB |
Output is correct |
3 |
Correct |
101 ms |
17888 KB |
Output is correct |
4 |
Correct |
116 ms |
16096 KB |
Output is correct |
5 |
Correct |
104 ms |
16136 KB |
Output is correct |
6 |
Correct |
96 ms |
16324 KB |
Output is correct |
7 |
Correct |
92 ms |
16152 KB |
Output is correct |
8 |
Correct |
87 ms |
16352 KB |
Output is correct |
9 |
Correct |
96 ms |
17888 KB |
Output is correct |
10 |
Correct |
96 ms |
16352 KB |
Output is correct |
11 |
Correct |
97 ms |
16356 KB |
Output is correct |
12 |
Correct |
101 ms |
17100 KB |
Output is correct |
13 |
Correct |
97 ms |
17088 KB |
Output is correct |
14 |
Correct |
100 ms |
17340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
8536 KB |
Output is correct |
2 |
Correct |
22 ms |
9304 KB |
Output is correct |
3 |
Correct |
27 ms |
10580 KB |
Output is correct |
4 |
Correct |
69 ms |
16088 KB |
Output is correct |
5 |
Correct |
87 ms |
15960 KB |
Output is correct |
6 |
Correct |
75 ms |
16208 KB |
Output is correct |
7 |
Correct |
72 ms |
17344 KB |
Output is correct |
8 |
Correct |
74 ms |
15840 KB |
Output is correct |
9 |
Incorrect |
87 ms |
16100 KB |
Output is incorrect: {s, t} is wrong. |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
7512 KB |
Output is correct |
2 |
Correct |
12 ms |
8336 KB |
Output is correct |
3 |
Correct |
73 ms |
14360 KB |
Output is correct |
4 |
Correct |
103 ms |
16092 KB |
Output is correct |
5 |
Correct |
97 ms |
18020 KB |
Output is correct |
6 |
Correct |
90 ms |
16100 KB |
Output is correct |
7 |
Correct |
91 ms |
17888 KB |
Output is correct |
8 |
Correct |
90 ms |
17928 KB |
Output is correct |
9 |
Incorrect |
95 ms |
16096 KB |
Output is incorrect: {s, t} is wrong. |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
8536 KB |
Output is correct |
2 |
Correct |
14 ms |
8708 KB |
Output is correct |
3 |
Correct |
121 ms |
16800 KB |
Output is correct |
4 |
Correct |
131 ms |
18140 KB |
Output is correct |
5 |
Correct |
154 ms |
18400 KB |
Output is correct |
6 |
Correct |
154 ms |
17748 KB |
Output is correct |
7 |
Correct |
146 ms |
17892 KB |
Output is correct |
8 |
Correct |
148 ms |
18136 KB |
Output is correct |
9 |
Correct |
124 ms |
15652 KB |
Output is correct |
10 |
Correct |
101 ms |
14848 KB |
Output is correct |
11 |
Correct |
111 ms |
16208 KB |
Output is correct |
12 |
Correct |
145 ms |
17336 KB |
Output is correct |
13 |
Correct |
151 ms |
17484 KB |
Output is correct |
14 |
Correct |
149 ms |
17948 KB |
Output is correct |
15 |
Correct |
148 ms |
19004 KB |
Output is correct |
16 |
Correct |
130 ms |
16456 KB |
Output is correct |
17 |
Correct |
91 ms |
18380 KB |
Output is correct |
18 |
Correct |
92 ms |
16036 KB |
Output is correct |
19 |
Correct |
102 ms |
18636 KB |
Output is correct |
20 |
Correct |
91 ms |
15976 KB |
Output is correct |
21 |
Correct |
140 ms |
18452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
8536 KB |
Output is correct |
2 |
Correct |
16 ms |
8784 KB |
Output is correct |
3 |
Correct |
108 ms |
16676 KB |
Output is correct |
4 |
Correct |
117 ms |
16764 KB |
Output is correct |
5 |
Correct |
125 ms |
17128 KB |
Output is correct |
6 |
Correct |
150 ms |
18348 KB |
Output is correct |
7 |
Correct |
107 ms |
16800 KB |
Output is correct |
8 |
Correct |
112 ms |
17016 KB |
Output is correct |
9 |
Correct |
121 ms |
17688 KB |
Output is correct |
10 |
Correct |
139 ms |
17892 KB |
Output is correct |
11 |
Correct |
144 ms |
18288 KB |
Output is correct |
12 |
Correct |
146 ms |
18388 KB |
Output is correct |
13 |
Correct |
106 ms |
15028 KB |
Output is correct |
14 |
Correct |
106 ms |
15484 KB |
Output is correct |
15 |
Correct |
113 ms |
15224 KB |
Output is correct |
16 |
Correct |
108 ms |
15476 KB |
Output is correct |
17 |
Correct |
105 ms |
15048 KB |
Output is correct |
18 |
Correct |
106 ms |
15068 KB |
Output is correct |
19 |
Correct |
155 ms |
17440 KB |
Output is correct |
20 |
Correct |
144 ms |
18680 KB |
Output is correct |
21 |
Correct |
144 ms |
17932 KB |
Output is correct |
22 |
Correct |
142 ms |
18076 KB |
Output is correct |
23 |
Correct |
147 ms |
18156 KB |
Output is correct |
24 |
Correct |
152 ms |
18036 KB |
Output is correct |
25 |
Correct |
150 ms |
19020 KB |
Output is correct |
26 |
Correct |
141 ms |
19028 KB |
Output is correct |
27 |
Correct |
93 ms |
18524 KB |
Output is correct |
28 |
Correct |
90 ms |
15748 KB |
Output is correct |
29 |
Correct |
89 ms |
18896 KB |
Output is correct |
30 |
Incorrect |
86 ms |
15816 KB |
Output is incorrect: {s, t} is wrong. |
31 |
Halted |
0 ms |
0 KB |
- |