This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//by szh
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl
#define pq priority_queue
#define inf 0x3f
#define rep(i,a,b) for (int i=a;i<(b);i++)
#define MP make_pair
#define SZ(x) (int(x.size()))
#define ll long long
#define mod 1000000007
#define ALL(x) x.begin(),x.end()
void inc(int &a,int b) {a=(a+b)%mod;}
void dec(int &a,int b) {a=(a-b+mod)%mod;}
int lowbit(int x) {return x&(-x);}
ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;}
#include "chameleon.h"
namespace {
vector <int> edge[550];
bool vis[550];
} // namespace
void Solve(int N) {
rep(i,1,2*N+1)
rep(j,1,i) {
int cnt = Query({i,j});
if (cnt==1) edge[i].pb(j),edge[j].pb(i);
}
rep(i,1,2*N+1) {
if (SZ(edge[i])==3) {
int x = edge[i][0], y = edge[i][1], z = edge[i][2];
if (Query({i,x,y})==1) edge[i] = {x,y};
else if (Query({i,x,z})==1) edge[i] = {x,z};
else {
// assert(Query({i,y,z})==1);
edge[i] = {y,z};
}
}
}
rep(i,1,2*N+1) {
if (vis[i]) continue;
if (SZ(edge[i])==1) {
Answer(i,edge[i][0]);
vis[i] = vis[edge[i][0]] = 1;
}
else {
assert(SZ(edge[i])==2);
int x = edge[i][0], y = edge[i][1];
if (vis[y] or SZ(edge[x])==1) {
Answer(i,x);
vis[i] = vis[x] = 1;
}
else if (vis[x] or SZ(edge[y])==1) {
Answer(i,y);
vis[i] = vis[y] = 1;
}
else {
if (edge[x][0]==i or edge[x][1]==i) Answer(i,x),vis[i]=vis[x]=1;
else assert(edge[y][0]==i or edge[y][1]==i),Answer(i,y),vis[i]=vis[y]=1;
}
}
}
return;
}
# | 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... |