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>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,1:0;}
template <typename T> bool chkmax(T &x,T y){return x<y?x=y,1:0;}
ll readint(){
ll x=0,f=1; char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
namespace {
int c[105][105],nxt[105];
vector<int> g[105];
bool done[105];
}
void Solve(int n){
for(int i=1;i<=2*n;i++){
for(int j=i+1;j<=2*n;j++){
c[i][j]=c[j][i]=Query({i,j});
}
}
for(int i=1;i<=2*n;i++){
for(int j=i+1;j<=2*n;j++){
if(c[i][j]==1){
g[i].pb(j);
g[j].pb(i);
}
}
}
vector<pii> res;
for(int i=1;i<=2*n;i++){
sort(g[i].begin(),g[i].end());
g[i].erase(unique(g[i].begin(),g[i].end()),g[i].end());
int sz=(int)g[i].size();
if(sz==3){
for(int x=0;x<3;x++){
vector<int> qv={i};
for(int y=0;y<3;y++) if(y!=x) qv.pb(g[i][y]);
if(Query(qv)==1){
nxt[i]=g[i][x];
break;
}
}
}else{
done[i]=true;
res.pb(mp(min(i,g[i][0]),max(i,g[i][0])));
}
}
for(int i=1;i<=2*n;i++){
if(done[i]) continue;
vector<int> cyc;
cyc.pb(i);
int ver=i;
while(!done[ver]) cyc.pb(ver),done[ver]=true,ver=nxt[ver];
for(int v:cyc){
for(int x:g[v]){
if(x!=nxt[v]&&nxt[x]!=v){
res.pb(mp(min(v,x),max(v,x)));
}
}
}
}
sort(res.begin(),res.end());
res.erase(unique(res.begin(),res.end()),res.end());
for(auto&p:res) Answer(p.fi,p.se);
}
# | 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... |