#include "chameleon.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
namespace {
int n, qcnt;
bool chk[1010], ok[1010];
vector<int> a, adj[1010];
bool myquery(int l, int r, vector<int> v){
vector<int> Q = v;
for (int i=l;i<=r;i++) Q.push_back(a[i]);
return Query(Q)!=(int)Q.size();
}
} // namespace
void Solve(int N) {
n = N;
vector<int> V, V2;
for (int i=1;i<=n*2;i++){
V.push_back(i);
}
mt19937 rng(546123);
shuffle(V.begin(), V.end(), rng);
for (int i=1;i<=n*2;i++){
V2.push_back(V[i-1]);
if (myquery(0, -1, V2)) V2.pop_back();
}
//for (auto &x:V) printf("%d ", x);
//printf("\n");
assert((int)V.size()==n);
a.push_back(0);
for (int i=1;i<=n;i++){
a.push_back(V[i-1]);
ok[V[i-1]] = 1;
}
for (int i=1;i<=n*2;i++) if (!ok[i]) a.push_back(i);
for (int i=1;i<=n;i++){
int prv = n;
while(true){
int l = prv+1, r = n*2-1, idx = n*2;
if (!myquery(l, n*2, {a[i]})) break;
while(l<=r){
int m = (l+r)>>1;
if (myquery(prv+1, m, {a[i]})) r = m-1, idx = m;
else l = m+1;
}
adj[a[i]].push_back(a[idx]);
adj[a[idx]].push_back(a[i]);
prv = idx;
}
/*printf("%d: ", i);
for (auto &x:adj[i]) printf("%d ", x);
printf("\n");*/
}
/*for (int i=1;i<=n*2;i++){
for (int j=i+1;j<=n*2;j++){
if (Query({i, j})==1){
adj[i].push_back(j);
adj[j].push_back(i);
}
}
}*/
for (int i=1;i<=n*2;i++) if (adj[i].size()!=1){
assert(adj[i].size()==3);
for (int k=0;k<3;k++){
vector<int> tmp = {i};
for (int l=0;l<3;l++) if (k!=l) tmp.push_back(adj[i][l]);
if (Query(tmp)==1){
adj[i].erase(adj[i].begin()+k);
break;
}
}
}
for (int i=1;i<=n*2;i++) if (!chk[i]){
for (int k=0;k<(int)adj[i].size();k++){
int v = adj[i][k];
if (find(adj[v].begin(), adj[v].end(), i)==adj[v].end()) continue;
Answer(i, v);
chk[i] = 1, chk[v] = 1;
}
assert(chk[i]);
}
}
Compilation message
chameleon.cpp:9:8: warning: '{anonymous}::qcnt' defined but not used [-Wunused-variable]
9 | int n, qcnt;
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
464 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
464 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
464 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
464 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
464 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |