Submission #423738

#TimeUsernameProblemLanguageResultExecution timeMemory
423738p_squareChameleon's Love (JOI20_chameleon)C++14
40 / 100
30 ms328 KiB
#include "chameleon.h" #include <bits/stdc++.h> #include <vector> using namespace std; void Solve(int n) { vector <int> qry; int h; vector <int> candid[2*n]; int sim[2*n], flove[2*n]; for(int i = 0; i<2*n; i++) { flove[i] = -1; for(int j = 0; j<i; j++) { qry.clear(); qry.push_back(i+1); qry.push_back(j+1); h = Query(qry); if(h == 1) { candid[i].push_back(j); candid[j].push_back(i); } } } int B; for(int i = 0; i<2*n; i++) { if(candid[i].size() == 1) { sim[i] = candid[i][0]; continue; } flove[i] = candid[i][0]; qry = {i+1, candid[i][0]+1, candid[i][1]+1}; h = Query(qry); if(h == 1) flove[i] = candid[i][2]; qry = {i+1, candid[i][0]+1, candid[i][2]+1}; h = Query(qry); if(h == 1) flove[i] = candid[i][1]; } for(int i = 0; i<2*n; i++) { if(candid[i].size() == 1) continue; for(int k = 0; k<3; k++) { B = candid[i][k]; if(flove[i] == B) continue; if(flove[B] == i) continue; sim[i] = B; } } for(int i = 0; i<2*n; i++) { if(sim[i] > i) Answer(i+1, sim[i]+1); } }
#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...