# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
923527 | 2024-02-07T11:34:48 Z | alexander707070 | Chameleon's Love (JOI20_chameleon) | C++14 | 0 ms | 0 KB |
#include <bits/stdc++.h> #include "chameleon.h" #define MAXN 1007 namespace { int n; } // namespace vector<int> to[MAXN]; void Solve(int N) { n=N; for(int i=1;i<=2*n;i++){ for(int f=i+1;f<=2*n;f++){ if(Query({i,f})==1){ to[i].push_back(f); to[f].push_back(i); } } } for(int i=1;i<=2*n;i++){ if(to[i].size()==1){ if(i<to[i][0])Answer(i,to[i][0]); }else{ for(int f:to[to[i][0]]){ if(f==i and i<to[i][0])Answer(i,to[i][0]); } for(int f:to[to[i][1]]){ if(f==i and i<to[i][1])Answer(i,to[i][1]); } } } }