Submission #335518

#TimeUsernameProblemLanguageResultExecution timeMemory
335518rocks03Minerals (JOI19_minerals)C++14
40 / 100
43 ms2908 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int, int> #define pll pair<ll, ll> #define ff first #define ss second #define pb push_back #define SZ(x) ((int)(x).size()) #define all(x) x.begin(), x.end() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int Query(int x); void Answer(int a, int b); vector<pii> risposta; int already; void dc(vector<int>& a, vector<int>& b){ assert(SZ(a) == SZ(b)); if(SZ(a) == 0) return; if(SZ(a) == 1){ already += 1; //Query(a[0]); risposta.pb({a[0], b[0]}); return; } int m = SZ(b) / 2, prev = already + SZ(a); for(int i = 0; i < m; i++){ Query(b[i]); } vector<int> b_left, b_right; for(int i = 0; i < SZ(a); i++){ int ans = Query(a[i]); if(ans < prev){ b_right.pb(a[i]); } else if(ans == prev){ b_left.pb(a[i]); } prev = ans; } vector<int> a_left, a_right; for(int i = 0; i < m; i++){ a_left.pb(b[i]); } dc(a_left, b_left); for(int i = m; i < SZ(b); i++){ Query(b[i]); a_right.pb(b[i]); } dc(a_right, b_right); } void Solve(int N){ vector<int> a, b; int prev = 0; vector<int> v(2 * N); iota(all(v), 1); shuffle(all(v), rng); for(int i = 0; i < 2 * N; i++){ int ans = Query(v[i]); if(ans == prev){ Query(v[i]); b.pb(v[i]); } else if(ans > prev){ a.pb(v[i]); } prev = ans; if(ans == N){ i++; while(i < 2 * N){ b.pb(v[i++]); } break; } } dc(a, b); for(auto x : risposta){ Answer(x.ff, x.ss); } }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...