#include "chameleon.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3+5;
namespace {
vector<int> g[maxn];
} // namespace
int bs_edge(vector<int> vec, int x){
int l = 0, r = vec.size()-2;
while(l < r){
int mid = (l+r+1)>>1;
vector<int> nw(vec.begin(), vec.begin()+mid);
nw.push_back(x);
if(Query(nw) != nw.size())r = mid-1;
else l = mid;
}
return vec[l];
}
void get_edge(vector<int> vec, int d = 2){
vector<int> bp, oth;
for(auto v: vec){
bp.push_back(v);
if(Query(bp) != bp.size()){
bp.pop_back();
oth.push_back(v);
}
}
vector<int> rmv;
for(auto v: oth){
vector<int> nw = bp;
nw.push_back(v);
bool first = 1;
while(g[v].size() < 3 && (first || Query(nw) != nw.size())){
first = 0;
int tmp = bs_edge(nw, v);
nw.erase(find(nw.begin(), nw.end(), tmp));
g[tmp].push_back(v);
g[v].push_back(tmp);
}
if(g[v].size() == 3)rmv.push_back(v);
}
for(auto v: rmv)oth.erase(find(oth.begin(), oth.end(), v));
if(d)get_edge(oth, d-1);
}
void Solve(int N) {
set<pair<int, int>> bad;
vector<int> vec(N*2);
iota(vec.begin(), vec.end(), 1);
get_edge(vec);
for(int i = 1; i <= 2*N; i++){
if(g[i].size() == 3){
g[i].push_back(i);
for(int j = 0; j < 3; j++){
vector<int> nw = g[i];
nw.erase(nw.begin() + j);
if(Query(nw) == 1){
bad.insert({i, g[i][j]});
bad.insert({g[i][j], i});
}
}
g[i].pop_back();
}
}
for(int i = 1; i <= 2*N; i++){
for(int v: g[i]){
if(v > i)continue;
if(bad.find({v, i}) == bad.end()){
Answer(v, i);
}
}
}
}
Compilation message
chameleon.cpp: In function 'int bs_edge(std::vector<int>, int)':
chameleon.cpp:17:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
17 | if(Query(nw) != nw.size())r = mid-1;
| ~~~~~~~~~~^~~~~~~~~~~~
chameleon.cpp: In function 'void get_edge(std::vector<int>, int)':
chameleon.cpp:27:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
27 | if(Query(bp) != bp.size()){
| ~~~~~~~~~~^~~~~~~~~~~~
chameleon.cpp:37:48: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
37 | while(g[v].size() < 3 && (first || Query(nw) != nw.size())){
| ~~~~~~~~~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
10 ms |
556 KB |
Output is correct |
4 |
Correct |
9 ms |
516 KB |
Output is correct |
5 |
Correct |
15 ms |
340 KB |
Output is correct |
6 |
Correct |
13 ms |
504 KB |
Output is correct |
7 |
Correct |
9 ms |
344 KB |
Output is correct |
8 |
Correct |
10 ms |
560 KB |
Output is correct |
9 |
Correct |
11 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
# |
Verdict |
Execution time |
Memory |
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 |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
24 ms |
600 KB |
Output is correct |
4 |
Correct |
24 ms |
564 KB |
Output is correct |
5 |
Correct |
27 ms |
600 KB |
Output is correct |
6 |
Correct |
23 ms |
720 KB |
Output is correct |
7 |
Correct |
23 ms |
548 KB |
Output is correct |
8 |
Correct |
24 ms |
592 KB |
Output is correct |
9 |
Correct |
38 ms |
556 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
10 ms |
556 KB |
Output is correct |
4 |
Correct |
9 ms |
516 KB |
Output is correct |
5 |
Correct |
15 ms |
340 KB |
Output is correct |
6 |
Correct |
13 ms |
504 KB |
Output is correct |
7 |
Correct |
9 ms |
344 KB |
Output is correct |
8 |
Correct |
10 ms |
560 KB |
Output is correct |
9 |
Correct |
11 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 |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
1 ms |
344 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
0 ms |
344 KB |
Output is correct |
22 |
Correct |
0 ms |
344 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
0 ms |
344 KB |
Output is correct |
25 |
Correct |
1 ms |
344 KB |
Output is correct |
26 |
Correct |
1 ms |
344 KB |
Output is correct |
27 |
Correct |
0 ms |
344 KB |
Output is correct |
28 |
Correct |
0 ms |
344 KB |
Output is correct |
29 |
Correct |
0 ms |
344 KB |
Output is correct |
30 |
Correct |
24 ms |
600 KB |
Output is correct |
31 |
Correct |
24 ms |
564 KB |
Output is correct |
32 |
Correct |
27 ms |
600 KB |
Output is correct |
33 |
Correct |
23 ms |
720 KB |
Output is correct |
34 |
Correct |
23 ms |
548 KB |
Output is correct |
35 |
Correct |
24 ms |
592 KB |
Output is correct |
36 |
Correct |
38 ms |
556 KB |
Output is correct |
37 |
Correct |
22 ms |
560 KB |
Output is correct |
38 |
Correct |
15 ms |
344 KB |
Output is correct |
39 |
Correct |
25 ms |
544 KB |
Output is correct |
40 |
Correct |
21 ms |
600 KB |
Output is correct |
41 |
Correct |
34 ms |
600 KB |
Output is correct |
42 |
Correct |
9 ms |
344 KB |
Output is correct |
43 |
Correct |
23 ms |
560 KB |
Output is correct |
44 |
Correct |
21 ms |
600 KB |
Output is correct |
45 |
Correct |
25 ms |
600 KB |
Output is correct |