#include "chameleon.h"
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
vector<int>edges[1010];
vector<int> likehell[4];
int lik[1010];
void proc(int i){
if(edges[i].size()<2)return;
vector<int>v=edges[i];
v.push_back(i);
for(auto k:edges[i]){
v.erase(find(all(v),k));
if(Query(v)<2)
lik[i]=k;
v.push_back(k);
}
}
int AE(int a,int b){
edges[a].push_back(b);
edges[b].push_back(a);
return b;
}
int dnc(int i,vector<int> v){
v.pop_back();
if(v.size()==1) return AE(i,v[0]);
vector<int>a,b;
for(int i=0;i<v.size();i++)
(i%2?a:b).push_back(v[i]);
a.push_back(i);
b.push_back(i);
return dnc(i,Query(a)<a.size()?a:b);
}
mt19937 rng(28974);
void Solve(int N) {
for(int i=1;i<=2*N;i++) {
int apos=0;
vector<int>ord{0,1,2,3};
shuffle(all(ord),rng);
for(auto j:ord){
if(likehell[j].size()&&edges[i].size()<3){
vector<int>v=likehell[j];
v.push_back(i);
while(Query(v)<v.size())
v.erase(find(all(v),dnc(i,v)));
if(v.size()>likehell[j].size())
apos=j;
}else apos=j;
}
likehell[apos].push_back(i);
}
for(int i=1;i<=2*N;i++)
proc(i);
for(int i=1;i<=2*N;i++)
if(lik[i])edges[i].erase(find(all(edges[i]),lik[i])),
edges[lik[i]].erase(find(all(edges[lik[i]]),i));
for(int i=1;i<=2*N;i++)
if(edges[i][0]>i)
Answer(edges[i][0],i);
}
Compilation message
chameleon.cpp: In function 'int dnc(int, std::vector<int>)':
chameleon.cpp:28:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
28 | for(int i=0;i<v.size();i++)
| ~^~~~~~~~~
chameleon.cpp:28:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
28 | for(int i=0;i<v.size();i++)
| ^~~
chameleon.cpp:30:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
30 | a.push_back(i);
| ^
chameleon.cpp:32:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | return dnc(i,Query(a)<a.size()?a:b);
| ~~~~~~~~^~~~~~~~~
chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:44:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
44 | while(Query(v)<v.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 |
344 KB |
Output is correct |
4 |
Correct |
10 ms |
344 KB |
Output is correct |
5 |
Correct |
10 ms |
344 KB |
Output is correct |
6 |
Correct |
10 ms |
344 KB |
Output is correct |
7 |
Correct |
10 ms |
344 KB |
Output is correct |
8 |
Correct |
10 ms |
488 KB |
Output is correct |
9 |
Correct |
10 ms |
548 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
380 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 |
1 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 |
380 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 |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 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 |
1 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 |
22 ms |
548 KB |
Output is correct |
4 |
Correct |
24 ms |
344 KB |
Output is correct |
5 |
Correct |
23 ms |
344 KB |
Output is correct |
6 |
Correct |
23 ms |
344 KB |
Output is correct |
7 |
Correct |
23 ms |
344 KB |
Output is correct |
8 |
Correct |
23 ms |
596 KB |
Output is correct |
9 |
Correct |
33 ms |
544 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 |
344 KB |
Output is correct |
4 |
Correct |
10 ms |
344 KB |
Output is correct |
5 |
Correct |
10 ms |
344 KB |
Output is correct |
6 |
Correct |
10 ms |
344 KB |
Output is correct |
7 |
Correct |
10 ms |
344 KB |
Output is correct |
8 |
Correct |
10 ms |
488 KB |
Output is correct |
9 |
Correct |
10 ms |
548 KB |
Output is correct |
10 |
Correct |
1 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 |
380 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 |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
1 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 |
1 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 |
22 ms |
548 KB |
Output is correct |
31 |
Correct |
24 ms |
344 KB |
Output is correct |
32 |
Correct |
23 ms |
344 KB |
Output is correct |
33 |
Correct |
23 ms |
344 KB |
Output is correct |
34 |
Correct |
23 ms |
344 KB |
Output is correct |
35 |
Correct |
23 ms |
596 KB |
Output is correct |
36 |
Correct |
33 ms |
544 KB |
Output is correct |
37 |
Correct |
29 ms |
344 KB |
Output is correct |
38 |
Correct |
11 ms |
484 KB |
Output is correct |
39 |
Correct |
22 ms |
344 KB |
Output is correct |
40 |
Correct |
22 ms |
344 KB |
Output is correct |
41 |
Correct |
22 ms |
344 KB |
Output is correct |
42 |
Correct |
10 ms |
344 KB |
Output is correct |
43 |
Correct |
30 ms |
344 KB |
Output is correct |
44 |
Correct |
22 ms |
556 KB |
Output is correct |
45 |
Correct |
22 ms |
344 KB |
Output is correct |