#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;
}
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();
cerr << h << "\n";
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;
}
}
cerr << s[l] << " " << h << "\n";
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 |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
228 KB |
Output is correct |
3 |
Correct |
21 ms |
340 KB |
Output is correct |
4 |
Correct |
26 ms |
340 KB |
Output is correct |
5 |
Correct |
23 ms |
208 KB |
Output is correct |
6 |
Correct |
20 ms |
332 KB |
Output is correct |
7 |
Correct |
23 ms |
344 KB |
Output is correct |
8 |
Correct |
21 ms |
336 KB |
Output is correct |
9 |
Correct |
21 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
2 ms |
208 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
1 ms |
208 KB |
Output is correct |
17 |
Correct |
2 ms |
208 KB |
Output is correct |
18 |
Correct |
2 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
31 ms |
340 KB |
Output is correct |
4 |
Correct |
32 ms |
336 KB |
Output is correct |
5 |
Correct |
33 ms |
316 KB |
Output is correct |
6 |
Correct |
49 ms |
340 KB |
Output is correct |
7 |
Correct |
33 ms |
336 KB |
Output is correct |
8 |
Correct |
32 ms |
332 KB |
Output is correct |
9 |
Correct |
32 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
228 KB |
Output is correct |
3 |
Correct |
21 ms |
340 KB |
Output is correct |
4 |
Correct |
26 ms |
340 KB |
Output is correct |
5 |
Correct |
23 ms |
208 KB |
Output is correct |
6 |
Correct |
20 ms |
332 KB |
Output is correct |
7 |
Correct |
23 ms |
344 KB |
Output is correct |
8 |
Correct |
21 ms |
336 KB |
Output is correct |
9 |
Correct |
21 ms |
336 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
208 KB |
Output is correct |
15 |
Correct |
0 ms |
208 KB |
Output is correct |
16 |
Correct |
1 ms |
208 KB |
Output is correct |
17 |
Correct |
1 ms |
208 KB |
Output is correct |
18 |
Correct |
1 ms |
208 KB |
Output is correct |
19 |
Correct |
1 ms |
208 KB |
Output is correct |
20 |
Correct |
1 ms |
208 KB |
Output is correct |
21 |
Correct |
1 ms |
208 KB |
Output is correct |
22 |
Correct |
1 ms |
208 KB |
Output is correct |
23 |
Correct |
2 ms |
208 KB |
Output is correct |
24 |
Correct |
1 ms |
208 KB |
Output is correct |
25 |
Correct |
1 ms |
208 KB |
Output is correct |
26 |
Correct |
2 ms |
208 KB |
Output is correct |
27 |
Correct |
2 ms |
208 KB |
Output is correct |
28 |
Correct |
0 ms |
208 KB |
Output is correct |
29 |
Correct |
0 ms |
208 KB |
Output is correct |
30 |
Correct |
31 ms |
340 KB |
Output is correct |
31 |
Correct |
32 ms |
336 KB |
Output is correct |
32 |
Correct |
33 ms |
316 KB |
Output is correct |
33 |
Correct |
49 ms |
340 KB |
Output is correct |
34 |
Correct |
33 ms |
336 KB |
Output is correct |
35 |
Correct |
32 ms |
332 KB |
Output is correct |
36 |
Correct |
32 ms |
336 KB |
Output is correct |
37 |
Correct |
32 ms |
336 KB |
Output is correct |
38 |
Correct |
22 ms |
208 KB |
Output is correct |
39 |
Correct |
32 ms |
348 KB |
Output is correct |
40 |
Correct |
33 ms |
336 KB |
Output is correct |
41 |
Correct |
35 ms |
208 KB |
Output is correct |
42 |
Correct |
24 ms |
336 KB |
Output is correct |
43 |
Correct |
32 ms |
336 KB |
Output is correct |
44 |
Correct |
35 ms |
368 KB |
Output is correct |
45 |
Correct |
33 ms |
332 KB |
Output is correct |