#include <cstdio>
#include <vector>
#include "library.h"
using namespace std;
void Solve(int n)
{
int lst = -1;
int cur = 1;
vector<vector<int>> adj(n+1 ,vector<int>());
int cnt = 0;
while(cnt < n - 1){
vector<int> t;
for(int j = 1 ; j <= n ; j++){
if(cur == j or j == lst) continue;
t.push_back(j);
}
int l = 0 , r = t.size()-1;
int res = -1;
while(l <= r){
int mid = l + r >> 1;
vector<int> m(n);
for(int j = 0 ; j <=mid ; j++) m[t[j]] = 1;
int c1 = Query(m);
m[cur-1] = 1;
int c2 = Query(m);
if(c1 == c2) res = mid , r = mid-1;
else l = mid+1;
}
if(res == -1){
cur = 1;
lst = adj[1][0];
}else{
res = t[res];
adj[cur].push_back(res);
lst = cur , cur = res, cnt++;
}
}
vector<int> res;
for(int i = 1; i <= n ; i++){
if(adj[i].size() == 1){
int t = i , p = i;
while(1){
res.push_back(t);
int c = 0;
for(auto x : adj[t]) if(x != p) p = t , t = x , c = 1;
if(c == 0) break;
}
}
}
Answer(res);
}
Compilation message
library.cpp: In function 'void Solve(int)':
library.cpp:23:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
23 | int mid = l + r >> 1;
| ~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
26 ms |
588 KB |
Wrong Answer [4] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
26 ms |
588 KB |
Wrong Answer [4] |
2 |
Halted |
0 ms |
0 KB |
- |