#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
long long ask(const std::vector<int> &w);
void answer(int s, int t);
void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) {
vector<vector<pair<int,int>>> adj(N);
for(int i=0;i<U.size();i++){
adj[U[i]].emplace_back(V[i],i);
adj[V[i]].emplace_back(U[i],i);
}
vector<int> pedge(N);
vector<int> depth(N);
function<void(int,int,int,int)> dfs = [&](int x,int p,int dep,int par){
depth[x]=dep;
pedge[x]=par;
for(auto&i:adj[x])if(i.first!=p)dfs(i.first,x,dep+1,i.second);
};
dfs(0,-1,0,-1);
int M = U.size();
auto base = ask(vector<int>(M));
auto basedep = base/((long long)A);
vector<int> sus;
for(int i=0;i<N;i++)if(depth[i]==basedep)sus.emplace_back(i);
while(sus.size()>1){
int mid = (sus.size())/2;
vector<int> left,right;
for(int i=0;i<mid;i++)left.emplace_back(sus[i]);
for(int i=mid;i<sus.size();i++)right.emplace_back(sus[i]);
vector<int> w(M);
for(int&i:left)w[pedge[i]]=1;
auto ans = ask(w);
if(ans!=base)sus=left;
else sus=right;
}
answer(0, sus[0]);
}
Compilation message
highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:11:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
11 | for(int i=0;i<U.size();i++){
| ~^~~~~~~~~
highway.cpp:32:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | for(int i=mid;i<sus.size();i++)right.emplace_back(sus[i]);
| ~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
7 ms |
1368 KB |
Output is correct |
3 |
Correct |
70 ms |
8432 KB |
Output is correct |
4 |
Correct |
67 ms |
8452 KB |
Output is correct |
5 |
Correct |
66 ms |
8436 KB |
Output is correct |
6 |
Correct |
64 ms |
8452 KB |
Output is correct |
7 |
Correct |
63 ms |
8448 KB |
Output is correct |
8 |
Correct |
61 ms |
8448 KB |
Output is correct |
9 |
Correct |
68 ms |
8272 KB |
Output is correct |
10 |
Correct |
63 ms |
8432 KB |
Output is correct |
11 |
Correct |
68 ms |
9836 KB |
Output is correct |
12 |
Correct |
65 ms |
10736 KB |
Output is correct |
13 |
Correct |
72 ms |
9968 KB |
Output is correct |
14 |
Correct |
70 ms |
9312 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
2136 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
508 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
199 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
205 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |