#include "bits/stdc++.h"
#include "highway.h"
#define all(v) v.begin() , v.end()
#define sz(a) (int)a.size()
using namespace std;
const int N = 1e5 + 5;
vector<int> v[N],Xor,depth[N],Res;
int n,m,A,B,Dist,vis[N],par[N],sub[N];
inline int oth(int c,int u) {return Xor[c] ^ u;}
void upd(int c,int d){
sub[c]=1;
depth[d].push_back(c);
for(int ind:v[c]){
int x = oth(ind,c);
if(ind==par[c] || vis[x]) continue;
par[x]=ind;
upd(x,d+1);
sub[c]+=sub[x];
}
}
int we_know_root(int rt){
for(int i=0;i<N;i++) depth[i].clear();
par[rt]=-1;
upd(rt,0);
int l = 0 , r = sz(depth[Dist]) - 1;
while(l<r){
int mid = (l+r)/2;
Res.assign(m,0);
for(int i=0;i<=mid;i++){
int cur = depth[Dist][i];
while(cur != rt){
Res[par[cur]]=1;
cur = oth(par[cur], cur);
}
}
if(ask(Res)==Dist*B) r=mid;
else l=mid+1;
}
return depth[Dist][l];
}
void find_pair(int _n, vector<int> U, vector<int> V, int _A, int _B){
A=_A,B=_B;
m = sz(U),n = _n;
for(int i=0;i<m;i++){
Xor.push_back(U[i]^V[i]);
v[U[i]].push_back(i);
v[V[i]].push_back(i);
}
Res.assign(m,0);
Dist = ask(Res) / A;
answer(0, we_know_root(0));
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
5968 KB |
Output is correct |
2 |
Correct |
3 ms |
5968 KB |
Output is correct |
3 |
Correct |
3 ms |
5968 KB |
Output is correct |
4 |
Correct |
3 ms |
5968 KB |
Output is correct |
5 |
Correct |
3 ms |
6136 KB |
Output is correct |
6 |
Correct |
3 ms |
5968 KB |
Output is correct |
7 |
Correct |
3 ms |
5968 KB |
Output is correct |
8 |
Correct |
3 ms |
5968 KB |
Output is correct |
9 |
Correct |
3 ms |
5968 KB |
Output is correct |
10 |
Correct |
3 ms |
5968 KB |
Output is correct |
11 |
Correct |
3 ms |
5968 KB |
Output is correct |
12 |
Correct |
2 ms |
5968 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
5968 KB |
Output is correct |
2 |
Correct |
11 ms |
6724 KB |
Output is correct |
3 |
Correct |
110 ms |
12028 KB |
Output is correct |
4 |
Correct |
99 ms |
11884 KB |
Output is correct |
5 |
Correct |
94 ms |
11816 KB |
Output is correct |
6 |
Correct |
106 ms |
11864 KB |
Output is correct |
7 |
Correct |
93 ms |
11892 KB |
Output is correct |
8 |
Correct |
96 ms |
11928 KB |
Output is correct |
9 |
Correct |
98 ms |
11804 KB |
Output is correct |
10 |
Correct |
113 ms |
11880 KB |
Output is correct |
11 |
Correct |
94 ms |
13824 KB |
Output is correct |
12 |
Correct |
114 ms |
14784 KB |
Output is correct |
13 |
Correct |
103 ms |
14048 KB |
Output is correct |
14 |
Incorrect |
111 ms |
13088 KB |
Output is incorrect: {s, t} is wrong. |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
7760 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
5968 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
49 ms |
35656 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
47 ms |
35644 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |