Submission #960579

#TimeUsernameProblemLanguageResultExecution timeMemory
960579Tuanlinh123Minerals (JOI19_minerals)C++17
100 / 100
33 ms6024 KiB
#include "minerals.h" #include<bits/stdc++.h> #define ll long long #define pb push_back #define sz(a) ((ll)(a).size()) using namespace std; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); void Solve(int n) { ll crr=0; vector <ll> A, B, a(n*2+1, 0); auto flip=[&](ll idx) { ll x=Query(idx)-crr; crr+=x, a[idx]^=1; return x; }; for (ll i=1; i<=n*2; i++) (flip(i)?A:B).pb(i); function <void(vector <ll>, vector <ll>, bool)> solve=[&](vector <ll> L, vector <ll> R, bool cr) { ll n=sz(L); if (n==1) {Answer(L[0], R[0]); return;} vector <ll> left, right; ll len=max(1.0, 0.4*n); for (ll i=0; i<len; i++) flip(L[i]); for (ll i:R) { if (sz(left)==len) right.pb(i); else if (sz(right)==n-len) left.pb(i); else (a[i]^(a[i]+flip(i))^cr?right:left).pb(i); } solve(vector <ll> (L.begin(), L.begin()+len), left, cr^1); solve(vector <ll> (L.begin()+len, L.end()), right, cr); }; solve(A, B, 1); }
#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...