Submission #1029104

#TimeUsernameProblemLanguageResultExecution timeMemory
1029104amirhoseinfar1385The Big Prize (IOI17_prize)C++17
20 / 100
379 ms1256 KiB
#include "prize.h" #include<bits/stdc++.h> using namespace std; map<int,pair<int,int>>mp; int cnt=0; pair<int,int>pors(int u){ if(mp.count(u)==0){ cnt++; if(cnt>=10000){ exit(23); } vector<int>hey=ask(u); mp[u]=make_pair(hey[0],hey[1]); } return mp[u]; } int find_best(int n) { int cnta=0; for(int i=0;i<n;){ //cout<<i<<endl; pair<int,int>av=pors(i); if(av.first+av.second==0){ return i; } cnta++; pair<int,int>fake; int low=i,high=n,mid; for(auto x:mp){ mid=x.first; fake=pors(mid); if(fake.first+fake.second!=av.first+av.second){ high=mid; }else{ if(fake.first-av.first==0){ low=mid; }else{ high=mid; } } } low=max(low,i); high=n; while(high-low>1){ mid=(high+low)>>1; fake=pors(mid); //cout<<i<<" "<<mid<<" "<<av.first<<" "<<av.second<<" "<<fake.first<<" "<<fake.second<<endl; if(fake.first+fake.second!=av.first+av.second){ high=mid; }else{ if(fake.first-av.first==0){ low=mid; }else{ high=mid; } } } i=low+1; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...