#include<bits/stdc++.h>
using namespace std;
#define intt long long
#define pb push_back
#define forr(i , x , y) for(int i = x; i <= y;i++)
#define fore(i , n) for(int i = 0 ; i < n;i++)
#define forn(i ,x , y) for(int i = x ; i >= y;i--)
long long ask(const vector<int> &w);
void answer(int s, int t);
const int MAXN = 90001;
intt a , b;
vector<pair<int ,int>> adj[MAXN];
vector<int> zeros , ones;
vector<int> nodes;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void dfs(int x , int p , intt val , intt dep)
{
if(dep == (val/b))
{
nodes.pb(x);
return;
}
for(auto [u , i] : adj[x])
{
if(u == p)
continue;
dfs(u , x , val ,dep + 1 );
}
}
int findT(int S)
{
intt val = ask(ones);
dfs(0 , -1 , val , 0);
int l = 0 , r = (int)nodes.size();
vector<int> asked = ones;
while(l + 1 < r)
{
int mid = (l + r)/2;
asked = ones;
forr(j , 0 , mid - 1) {
for(auto [u , i] : adj[nodes[j]])
asked[i] = 0;
}
if(ask(asked) == val)
l = mid;
else
r = mid;
}
return nodes[l];
}
void find_pair(int N, vector<int> U, vector<int> V, int A, int B)
{
a = A , b = B;
int m = (int)U.size();
zeros.assign(m , 0);
ones.assign(m , 1);
fore(i , N)adj[i].clear();
fore(i , m)
{
adj[U[i]].pb({V[i] , i});
adj[V[i]].pb({U[i] , i});
}
answer(0 ,findT(0));
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
2 ms |
2392 KB |
Output is correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Correct |
1 ms |
2392 KB |
Output is correct |
10 |
Correct |
1 ms |
2392 KB |
Output is correct |
11 |
Correct |
2 ms |
2392 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
7 ms |
3136 KB |
Output is correct |
3 |
Correct |
73 ms |
8516 KB |
Output is correct |
4 |
Correct |
66 ms |
8492 KB |
Output is correct |
5 |
Correct |
68 ms |
8488 KB |
Output is correct |
6 |
Correct |
67 ms |
8412 KB |
Output is correct |
7 |
Correct |
70 ms |
8524 KB |
Output is correct |
8 |
Correct |
61 ms |
8508 KB |
Output is correct |
9 |
Correct |
61 ms |
8404 KB |
Output is correct |
10 |
Correct |
69 ms |
8484 KB |
Output is correct |
11 |
Correct |
64 ms |
8080 KB |
Output is correct |
12 |
Correct |
64 ms |
8356 KB |
Output is correct |
13 |
Correct |
58 ms |
8252 KB |
Output is correct |
14 |
Correct |
67 ms |
8612 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
7 ms |
2904 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2392 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
11 ms |
3800 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
3160 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |