Submission #81110

#TimeUsernameProblemLanguageResultExecution timeMemory
81110giorgikobThe Big Prize (IOI17_prize)C++14
0 / 100
4 ms2680 KiB
#include "prize.h" #include<bits/stdc++.h> #define F first #define S second using namespace std; pair<int,int>p,p1; vector<int>v,v1; int A[200005]; int ANS[200005]; int ANS1[200005]; int ans=-1; void go(int L,int R) { if(ans>=0)return ; if(L>R)return; if(L==R) { v.clear(); if(ANS[L]>=0) v.push_back(ANS[L]),v.push_back(ANS1[L]); else v=ask(L),ANS[L]=v[0],ANS1[L]=v[1]; A[v[0]]=min(A[v[0]],L); if(v[0]+v[1]==0) { ans=L; return; } return; } else { v1.clear(); if(ANS[R]>=0) v1.push_back(ANS[R]),v1.push_back(ANS1[R]); else v1=ask(R),ANS[R]=v1[0],ANS1[R]=v1[1]; A[v1[0]]=min(A[v1[0]],R); if(v1[0]+v1[1]==0) { ans=R; return; } v.clear(); if(ANS[L]>=0) v.push_back(ANS[L]),v.push_back(ANS1[L]); else v=ask(L),ANS[L]=v[0],ANS1[L]=v[1]; A[v[0]]=min(A[v[0]],L); if(v[0]+v[1]==0) { ans=L; return; } if(v[0]==v1[0] || v[1]==v1[1])return; int mid=(L+R)/2; v.clear(); if(ANS[mid]>=0) v.push_back(ANS[mid]),v.push_back(ANS1[mid]); else v=ask(mid),ANS[mid]=v[0],ANS1[mid]=v[1]; if(ans==-1) if(v[0]==ANS[L]) { go(mid+1,R); } else if(v[0]==ANS[R]) { go(L,mid-1); } else { go(L,mid-1); if(ans==-1) go(mid+1,R); } } } int find_best(int n) { for(int i=0;i<n;i++) ANS[i]=ANS1[i]=-1; if(n==1) return 0; for(int i=0;i<n;i++) A[i]=1e9; int mid=(n-1)/2; go(0,mid); if(ans==-1) go(mid+1,n-1); return ans; }

Compilation message (stderr)

prize.cpp: In function 'void go(int, int)':
prize.cpp:62:5: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
   if(ans==-1)
     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...