Submission #245439

#TimeUsernameProblemLanguageResultExecution timeMemory
245439TadijaSebezChameleon's Love (JOI20_chameleon)C++14
44 / 100
37 ms416 KiB
#include "chameleon.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define pii pair<int,int> void Solve(int n) { if(n<=50){ vector<bool> was(n*2+1,false); vector<vector<int>> cand(n*2+1,vector<int>()); set<pii> bad; for(int j=1;j<=n*2;j++){ for(int i=1;i<=n*2;i++)if(i!=j){ if(Query({j,i})==1)cand[j].pb(i); } assert(cand[j].size()==1||cand[j].size()==3); if(cand[j].size()==3){ int A=Query({j,cand[j][0],cand[j][1]}); int B=Query({j,cand[j][1],cand[j][2]}); int C=Query({j,cand[j][2],cand[j][0]}); if(A==1)bad.insert({j,cand[j][2]}); if(B==1)bad.insert({j,cand[j][0]}); if(C==1)bad.insert({j,cand[j][1]}); } } for(int j=1;j<=n*2;j++){ if(was[j])continue; for(int i:cand[j]){ if(!bad.count({i,j})&&!bad.count({j,i})){ Answer(i,j); was[i]=was[j]=true; break; } } } }else{ vector<bool> was(n*2+1,false); for(int j=1;j<=n*2;j++){ if(was[j])continue; vector<int> all; for(int i=1;i<=n*2;i++)if(i!=j)all.pb(i); while(all.size()>1){ vector<int> v[2]; for(int i=0;i<all.size();i++)v[i&1].pb(all[i]); int A=Query(v[0]); v[0].pb(j); int B=Query(v[0]); v[0].pop_back(); if(A==B)all=v[0]; else all=v[1]; } was[all[0]]=was[j]=true; Answer(j,all[0]); } } }

Compilation message (stderr)

chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:44:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<all.size();i++)v[i&1].pb(all[i]);
                 ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...