제출 #348973

#제출 시각아이디문제언어결과실행 시간메모리
348973KerimHighway Tolls (IOI18_highway)C++17
18 / 100
260 ms6172 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...