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) {
vector<int> vis(n*2+1),deg(n*2+1);
vector<int> adj[n*2+1];
map<pair<int,int>,int> m;
for(int i=1;i<=n*2;i++){
for(int j=i+1;j<=n*2;j++){
if(Query({i,j})==1){
//cout<<i<<' '<<j<<endl;
adj[i].push_back(j);
adj[j].push_back(i);
deg[i]++,deg[j]++;
}
}
}
for(int i=1;i<=n*2;i++){
if(vis[i])continue;
if(deg[i]==1){
Answer(i,adj[i][0]);
vis[i]=1;
vis[adj[i][0]]=1;
}
}
for(int i=1;i<=n*2;i++){
if(vis[i])continue;
vector<int> t;
for(int j:adj[i]){
//if(vis[j])continue;
t.push_back(j);
//cout<<j<<' ';
}
//cout<<endl;
vector<int> rec(3);
rec[0]=Query({t[0],t[1],i});
rec[1]=Query({t[0],t[2],i});
rec[2]=Query({t[1],t[2],i});
auto upd=[&](int a,int b){
if(a>b)swap(a,b);
if(m[{a,b}])Answer(a,b);
m[{a,b}]++;
};
if(rec[0]==1){
upd(i,t[0]);
upd(i,t[1]);
}
if(rec[1]==1){
upd(i,t[0]);
upd(i,t[2]);
}
if(rec[2]==1){
upd(i,t[1]);
upd(i,t[2]);
}
}
}
# | 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... |