Submission #935128

#TimeUsernameProblemLanguageResultExecution timeMemory
935128freedommo33Chameleon's Love (JOI20_chameleon)C++17
40 / 100
15 ms344 KiB
#include <bits/stdc++.h> #include "chameleon.h" #include <vector> #define query Query #define answer Answer constexpr int M = 1005; using namespace std; vector<vector<int>> sasiedzi(M); vector<vector<int>> g(M); int syn[M]; bool uzyte[M]; void Solve(int n) { for(int i=1; i<=n*2; i++){ for(int j=1; j<=n*2; j++){ if(i==j) continue; if(query({i, j}) == 1) sasiedzi[i].push_back(j); } } //for(int i=1; i<=2*n; i++){ //cout<<i<<": "; //for(auto j:sasiedzi[i]) cout<<j<<" "; //cout<<endl; //} //cout<<endl; for(int i=1; i<=n*2; i++){ //cout<<"I: "<<i<<" "<<sasiedzi[i].size()<<endl; if(sasiedzi[i].size()!=1){ //cout<<i<<"S: "<<sasiedzi[i][0]<<" "<<sasiedzi[i][1]<<" "<<sasiedzi[i][2]<<endl; if(query({i, sasiedzi[i][0], sasiedzi[i][1]})==1) syn[i] = sasiedzi[i][2]; if(query({i, sasiedzi[i][0], sasiedzi[i][2]})==1) syn[i] = sasiedzi[i][1]; if(query({i, sasiedzi[i][2], sasiedzi[i][1]})==1) syn[i] = sasiedzi[i][0]; } } for(int i=1; i<=n*2; i++){ if(syn[i]!=0){ g[i].push_back(syn[i]); g[syn[i]].push_back(i); } } //cout<<"XD"<<endl; for(int i=1; i<=n*2; i++){ sort(g[i].begin(), g[i].end()); if(syn[i]==0){ if(uzyte[min(i, sasiedzi[i][0])] == 0){ //cout<<i<<","<<sasiedzi[i][0]<<endl; uzyte[min(i, sasiedzi[i][0])] = 1; answer(i, sasiedzi[i][0]); } } else{ if(g[i][0] == sasiedzi[i][0] && g[i][1] == sasiedzi[i][1]){ if(uzyte[min(i, sasiedzi[i][2])] == 0){ //cout<<i<<","<<sasiedzi[i][2]<<endl; uzyte[min(i, sasiedzi[i][2])] = 1; answer(i, sasiedzi[i][2]); } } else if(g[i][0] == sasiedzi[i][0] && g[i][1] == sasiedzi[i][2]){ if(uzyte[min(i, sasiedzi[i][1])] == 0){ //cout<<i<<","<<sasiedzi[i][1]<<endl; uzyte[min(i, sasiedzi[i][1])] = 1; answer(i, sasiedzi[i][1]); } } else if(g[i][0] == sasiedzi[i][1] && g[i][1] == sasiedzi[i][2]){ if(uzyte[min(i, sasiedzi[i][0])] == 0){ //cout<<i<<","<<sasiedzi[i][0]<<endl; uzyte[min(i, sasiedzi[i][0])] = 1; answer(i, sasiedzi[i][0]); } } } } }
#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...