Submission #260403

#TimeUsernameProblemLanguageResultExecution timeMemory
260403aggu_01000101The Big Prize (IOI17_prize)C++14
0 / 100
4 ms2340 KiB
#include <iostream> #include "prize.h" #include <algorithm> #include <vector> #include <set> #include <string> #include <queue> #include <map> #include <bits/stdc++.h> #define initrand mt19937 mt_rand(time(0)); #define rand mt_rand() //#define int long long #define INF 10000000000000000 #define MOD 1000000007 using namespace std; initrand; /*vector<int> ask(int x){ cout<<"QUERY AT "<<x<<endl; vector<int> tr = {0, 0}; cin>>tr[0]>>tr[1]; return tr; }*/ int get(int l, int r){ return (((rand%(r-l+1))) + l); } signed find_best(signed n){ vector<int> v; for(int i =1 ;i<=n;i++) v.push_back(i); bool found = false; map<int, int> first; map<int, int> last; int ans = -1; int q = 0; while(!found){ int tq = get(0, v.size() - 1); signed ta = v[tq]; //we will ask this vector<int> qq = ask(ta-1); q++; assert(q<=10000); if(qq[0] == qq[1] && qq[1]==0){ ans = ta; found = true; continue; } if(first[qq[0]] != 0){ auto it = upper_bound(v.begin(), v.end(), first[qq[0]]); auto it1 = lower_bound(v.begin(), v.end(), ta); v.erase(it, it1); first[qq[0]] = min(first[qq[0]], ta); } else first[qq[0]] = ta; if(last[qq[1]] != 0){ auto it = lower_bound(v.begin(), v.end(), ta); auto it1 = lower_bound(v.begin(), v.end(), last[qq[1]]); v.erase(it, it1); last[qq[1]] = max(last[qq[1]], ta); } else last[qq[1]] = ta; auto it = lower_bound(v.begin(), v.end(), ta); while(it!=v.end() && (*it) == ta) { //cout << "We should be erasing " << (*it) << endl; v.erase(it); it = lower_bound(v.begin(), v.end(), ta); } /*cout<<"Remaining array: "<<endl; for(int j: v){ cout<<j<<" "; } cout<<endl;*/ } return (ans-1); } /* signed main(){ signed n; cin>>n; int ans = find_best(n); cout<<"Final answer: "<<ans<<endl; } 11 12 0 1 3 0 2 4 2 3 5 3 4 4 4 5 6 0 6 3 6 7 2 6 8 5 8 9 6 8 10 7 */ /* 3 3 0 1 1 1 2 1 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...