이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "highway.h"
#include "bits/stdc++.h"
#define MAXN 130009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x) cerr<< #x <<" = "<< x<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int M,N;
PII edge[MAXN];
vector<int>A,B,AA,BB;
bool check(){
if(A.empty() or B.empty())
return 0;
vector<int>col(N),w(M);
tr(it,A)col[*it]=0;
tr(it,B)col[*it]=1;
for(int i=0;i<M;i++)
w[i]=(col[edge[i].ff]==col[edge[i].ss]);
return ask(w)%2;
}
void find_pair(int N, vector<int> U, vector<int> V, int a, int b) {
assert(a==1 and b==2);
M=U.size();::N=N;
for(int i=0;i<M;i++)
edge[i]=mp(U[i],V[i]);
int hor=0,who=-1;
for(int i=0;i<17;i++){
A.clear();B.clear();
for(int j=0;j<N;j++){
if(j>>i&1)A.pb(j);
else B.pb(j);
}
if(check()) hor^=(1<<i),who=i;
}A.clear();B.clear();assert(who!=-1);
for(int j=0;j<N;j++){
if(j>>who&1)A.pb(j);
else B.pb(j);
}int sz=A.size();
while(sz>1){
AA=A;BB=B;
A.clear();
for(int i=0;i<sz/2;i++)A.pb(AA[i]);
for(int i=sz/2;i<sz;i++)B.pb(AA[i]);
if(!check()){
B=BB;A.clear();
for(int i=sz/2;i<sz;i++)
A.pb(AA[i]);
}sz=A.size();
}
answer(A[0],A[0]^hor);
}
| # | 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... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |