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;
void Solve(int n) {
n*=2;
vector<vector<int>>adjs(n+1);
vector<int>sizs(n+1, 0);
for(int i=1; i<=n; i++){
for(int j=i+1; j<=n; j++){
if(Query({i, j})==1){
adjs[i].push_back(j);
adjs[j].push_back(i);
}
}
}
vector<bool>vis(n+1, 0);
vector<vector<int>>B(n+1);
for(int i=1; i<=n; i++){
if(vis[i]==1)continue;
if(adjs[i].size()==1){
Answer(i, adjs[i][0]);
vis[i]=1;
vis[adjs[i][0]]=1;
}else{
for(int j=0; j<3; j++){
vector<int>A={i};
for(int a=0;a<=2; a++){
if(a!=j)A.push_back(adjs[i][a]);
}
if(Query(A)==1){
B[i].push_back(adjs[i][j]);
B[adjs[i][j]].push_back(i);
break;
}
}
}
}
for(int i=1; i<=n; i++){
if(vis[i]==1)continue;
for(int a:adjs[i]){
if(a!=B[i][0]&&a!=B[i][1]){
Answer(i, a);
vis[i]=1, vis[a]=1;
break;
}
}
}
}
# | 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... |