This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |