#include "chameleon.h"
#include <bits/stdc++.h>
//#include "grader.cpp"
using namespace std;
namespace {
int variable_example = 1;
int n;
} // namespace
bool find(int x,int y){
vector<int> g;
for(int i=1;i<=n;i++){
if(i==x || i==y){
continue;
}
g.push_back(i);
}
int z=Query(g);
return z==(n/2-1);
}
mt19937 rnd(time(NULL));
void Solve(int N) {
n=2*N;
vector<int> tt(n);
iota(tt.begin(),tt.end(),1);
while(tt.size()>2){
shuffle(tt.begin(),tt.end(),rnd);
vector<int> s,t;
for(auto h:tt){
if(!s.size()){
s.push_back(h);
continue;
}
s.push_back(h);
if(Query(s)==s.size()){
continue;
}
s.pop_back();
int l=0,r=((int)s.size())-1;
while(r>l){
int m=(l+r)/2;
vector<int> tmp;
for(int i=0;i<=m;i++){
tmp.push_back(s[i]);
}
tmp.push_back(h);
if(Query(tmp)<=(int)tmp.size()-1){
r=m;
}
else{
l=m+1;
}
}
if(find(s[l],h)){
Answer(s[l],h);
swap(s[l],s.back());
s.pop_back();
}
else{
t.push_back(h);
}
}
s.insert(s.end(),t.begin(),t.end());
tt.swap(s);
}
if(tt.size()){
Answer(tt[0],tt[1]);
}
}
Compilation message
chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:37:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
37 | if(Query(s)==s.size()){
| ~~~~~~~~^~~~~~~~~~
chameleon.cpp: At global scope:
chameleon.cpp:8:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
8 | int variable_example = 1;
| ^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
17 ms |
328 KB |
Output is correct |
4 |
Correct |
18 ms |
332 KB |
Output is correct |
5 |
Correct |
18 ms |
336 KB |
Output is correct |
6 |
Correct |
17 ms |
328 KB |
Output is correct |
7 |
Correct |
19 ms |
208 KB |
Output is correct |
8 |
Correct |
18 ms |
332 KB |
Output is correct |
9 |
Correct |
17 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Incorrect |
4 ms |
208 KB |
Wrong Answer [3] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Incorrect |
4 ms |
208 KB |
Wrong Answer [3] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Incorrect |
4 ms |
208 KB |
Wrong Answer [3] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
17 ms |
328 KB |
Output is correct |
4 |
Correct |
18 ms |
332 KB |
Output is correct |
5 |
Correct |
18 ms |
336 KB |
Output is correct |
6 |
Correct |
17 ms |
328 KB |
Output is correct |
7 |
Correct |
19 ms |
208 KB |
Output is correct |
8 |
Correct |
18 ms |
332 KB |
Output is correct |
9 |
Correct |
17 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Incorrect |
4 ms |
208 KB |
Wrong Answer [3] |
12 |
Halted |
0 ms |
0 KB |
- |