Submission #260422

#TimeUsernameProblemLanguageResultExecution timeMemory
260422aggu_01000101The Big Prize (IOI17_prize)C++14
20 / 100
190 ms19436 KiB
#include <iostream> #include "prize.h" #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> #include <functional> #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() using namespace std; using namespace __gnu_pbds; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset; //#define int long long #define INF 10000000000000000 #define MOD 1000000007 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){ oset v; for(int i =1 ;i<=n;i++) v.insert(i); bool found = false; map<int, int> first; map<int, int> last; int ans = -1; int q = 0; while(!found){ if(q>=10000){ found = true; int tq = get(0, v.size() - 1); ans = *v.find_by_order(tq) - 1; continue; } int tq = get(0, v.size() - 1); signed ta = *v.find_by_order(tq); //we will ask this vector<int> qq = ask(ta-1); q++; if(qq[0] == qq[1] && qq[1]==0){ ans = ta; found = true; continue; } int ll = ta; if(first[qq[0]] != 0) ll = min(ll, first[qq[0]]); else first[qq[0]] = ta; int rr = ta + 1; rr = max(rr, last[qq[1]]); int rrr = v.order_of_key(rr) - 1; int lll = v.order_of_key(ll); for(int temp = rrr;temp>=lll;temp--) v.erase(v.find_by_order(temp)); first[qq[0]] = min(first[qq[0]], ta); last[qq[1]] = max(last[qq[1]], 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...