#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});
}
vector<int> w(m,0);
int l=ask(w);
vector<int> w2(m,1);
while(true){
int s=0;
for(auto e:w2) s+=e;
if(s==1) break;
auto w3=w2;
int s2=s/2;
for(int j=0;j<m;j++){
if(w3[j]){
s2--;
w3[j]=0;
if(s2==0) break;
}
}
int l2=ask(w3);
if(l2==l){
for(int j=0;j<m;j++){
if(w3[j]==0&&w2[j]==1){
w3[j]=1;
}
else if(w3[j]&&w2[j]){
w3[j]=0;
}
}
}
w2=w3;
}
int u=-1,v=-1,uv=-1;
for(int i=0;i<m;i++){
if(w2[i]){
u=p[i],v=q[i],uv=i;
}
}
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 |
2 ms |
7512 KB |
Output is correct |
2 |
Correct |
2 ms |
7512 KB |
Output is correct |
3 |
Correct |
2 ms |
7512 KB |
Output is correct |
4 |
Correct |
2 ms |
7512 KB |
Output is correct |
5 |
Correct |
2 ms |
7512 KB |
Output is correct |
6 |
Correct |
2 ms |
7512 KB |
Output is correct |
7 |
Correct |
1 ms |
7512 KB |
Output is correct |
8 |
Correct |
2 ms |
7512 KB |
Output is correct |
9 |
Correct |
1 ms |
7512 KB |
Output is correct |
10 |
Correct |
1 ms |
7512 KB |
Output is correct |
11 |
Correct |
2 ms |
7512 KB |
Output is correct |
12 |
Correct |
1 ms |
7512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
7512 KB |
Output is correct |
2 |
Correct |
11 ms |
8464 KB |
Output is correct |
3 |
Correct |
101 ms |
18248 KB |
Output is correct |
4 |
Correct |
112 ms |
16576 KB |
Output is correct |
5 |
Correct |
89 ms |
16680 KB |
Output is correct |
6 |
Correct |
102 ms |
18400 KB |
Output is correct |
7 |
Correct |
101 ms |
16608 KB |
Output is correct |
8 |
Correct |
92 ms |
16536 KB |
Output is correct |
9 |
Correct |
89 ms |
16656 KB |
Output is correct |
10 |
Correct |
113 ms |
18388 KB |
Output is correct |
11 |
Correct |
94 ms |
17028 KB |
Output is correct |
12 |
Correct |
104 ms |
17512 KB |
Output is correct |
13 |
Correct |
93 ms |
17872 KB |
Output is correct |
14 |
Correct |
96 ms |
17600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
8536 KB |
Output is correct |
2 |
Correct |
17 ms |
9500 KB |
Output is correct |
3 |
Correct |
25 ms |
10708 KB |
Output is correct |
4 |
Correct |
74 ms |
16604 KB |
Output is correct |
5 |
Correct |
70 ms |
16300 KB |
Output is correct |
6 |
Correct |
76 ms |
17624 KB |
Output is correct |
7 |
Correct |
76 ms |
17628 KB |
Output is correct |
8 |
Correct |
70 ms |
16812 KB |
Output is correct |
9 |
Correct |
71 ms |
17440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
7512 KB |
Output is correct |
2 |
Correct |
11 ms |
8536 KB |
Output is correct |
3 |
Correct |
66 ms |
14508 KB |
Output is correct |
4 |
Correct |
94 ms |
18140 KB |
Output is correct |
5 |
Correct |
97 ms |
18240 KB |
Output is correct |
6 |
Correct |
91 ms |
18392 KB |
Output is correct |
7 |
Correct |
94 ms |
18392 KB |
Output is correct |
8 |
Correct |
106 ms |
18380 KB |
Output is correct |
9 |
Correct |
100 ms |
17120 KB |
Output is correct |
10 |
Correct |
109 ms |
18388 KB |
Output is correct |
11 |
Correct |
103 ms |
17108 KB |
Output is correct |
12 |
Correct |
96 ms |
17600 KB |
Output is correct |
13 |
Correct |
101 ms |
16956 KB |
Output is correct |
14 |
Correct |
100 ms |
17036 KB |
Output is correct |
15 |
Correct |
96 ms |
16600 KB |
Output is correct |
16 |
Correct |
96 ms |
16568 KB |
Output is correct |
17 |
Correct |
96 ms |
17100 KB |
Output is correct |
18 |
Correct |
114 ms |
17100 KB |
Output is correct |
19 |
Correct |
91 ms |
18396 KB |
Output is correct |
20 |
Correct |
95 ms |
17304 KB |
Output is correct |
21 |
Correct |
74 ms |
16020 KB |
Output is correct |
22 |
Correct |
91 ms |
18848 KB |
Output is correct |
23 |
Correct |
87 ms |
16728 KB |
Output is correct |
24 |
Correct |
92 ms |
16640 KB |
Output is correct |
25 |
Correct |
100 ms |
17784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
8756 KB |
Output is correct |
2 |
Correct |
13 ms |
8648 KB |
Output is correct |
3 |
Correct |
110 ms |
17020 KB |
Output is correct |
4 |
Correct |
113 ms |
17492 KB |
Output is correct |
5 |
Correct |
148 ms |
19768 KB |
Output is correct |
6 |
Incorrect |
131 ms |
20028 KB |
Output is incorrect: {s, t} is wrong. |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
8536 KB |
Output is correct |
2 |
Correct |
13 ms |
8780 KB |
Output is correct |
3 |
Correct |
102 ms |
18680 KB |
Output is correct |
4 |
Correct |
123 ms |
17088 KB |
Output is correct |
5 |
Incorrect |
119 ms |
17392 KB |
Output is incorrect: {s, t} is wrong. |
6 |
Halted |
0 ms |
0 KB |
- |