#include "bits/stdc++.h"
#include "highway.h"
#define ll long long
#define all(v) v.begin() , v.end()
#define sz(a) (ll)a.size()
using namespace std;
const ll N = 2e5 + 5;
vector<ll> v[N],Xor,depth[N];
vector<int> Res;
ll n,m,A,B,Dist,vis[N],par[N],sub[N];
inline ll oth(ll c,ll u) {return Xor[c] ^ u;}
void upd(ll c,ll d){
sub[c]=1;
depth[d].push_back(c);
for(ll ind:v[c]){
ll x = oth(ind,c);
if(ind==par[c] || vis[x]) continue;
par[x]=ind;
upd(x,d+1);
sub[c]+=sub[x];
}
}
ll we_know_root(ll rt){
for(ll i=0;i<N;i++) depth[i].clear();
par[rt]=-1;
upd(rt,0);
ll l = 0 , r = sz(depth[Dist]) - 1;
while(l<r){
ll mid = (l+r)/2;
Res.assign(m,0);
for(ll i=0;i<=mid;i++){
ll 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(ll 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, (int) we_know_root(0));
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
12112 KB |
Output is correct |
2 |
Correct |
5 ms |
12112 KB |
Output is correct |
3 |
Correct |
4 ms |
12112 KB |
Output is correct |
4 |
Correct |
3 ms |
12112 KB |
Output is correct |
5 |
Correct |
3 ms |
12284 KB |
Output is correct |
6 |
Correct |
3 ms |
12112 KB |
Output is correct |
7 |
Correct |
3 ms |
12112 KB |
Output is correct |
8 |
Correct |
3 ms |
12112 KB |
Output is correct |
9 |
Correct |
4 ms |
12112 KB |
Output is correct |
10 |
Correct |
4 ms |
12112 KB |
Output is correct |
11 |
Correct |
4 ms |
12112 KB |
Output is correct |
12 |
Correct |
4 ms |
12112 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
12368 KB |
Output is correct |
2 |
Correct |
13 ms |
13136 KB |
Output is correct |
3 |
Correct |
108 ms |
19504 KB |
Output is correct |
4 |
Correct |
96 ms |
19432 KB |
Output is correct |
5 |
Correct |
93 ms |
19252 KB |
Output is correct |
6 |
Correct |
101 ms |
19348 KB |
Output is correct |
7 |
Correct |
100 ms |
19484 KB |
Output is correct |
8 |
Correct |
96 ms |
19460 KB |
Output is correct |
9 |
Correct |
99 ms |
20248 KB |
Output is correct |
10 |
Correct |
112 ms |
19436 KB |
Output is correct |
11 |
Correct |
105 ms |
20788 KB |
Output is correct |
12 |
Correct |
113 ms |
21692 KB |
Output is correct |
13 |
Correct |
94 ms |
20924 KB |
Output is correct |
14 |
Correct |
93 ms |
20156 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
14 ms |
13904 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
12368 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
87 ms |
72008 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
84 ms |
71752 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |