Submission #674939

#TimeUsernameProblemLanguageResultExecution timeMemory
674939uroskMinerals (JOI19_minerals)C++14
100 / 100
62 ms4200 KiB
#include "minerals.h"
#define here cerr<<"===========================================\n"
#define dbg(x) cerr<<#x<<": "<<x<<endl;
#include "bits/stdc++.h"
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
#define ld double
#define ll int
#define llinf 100000000000000000LL // 10^17
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define sz(a) (ll)(a.size())
#define all(a) a.begin(),a.end()
#define ceri(a,l,r) {cerr<<#a<<": ";for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
#define cer(a) {cerr<<#a<<": ";for(ll x_ : a) cerr<<x_<< " ";cerr<<endl;}

#define daj_mi_malo_vremena ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0);

using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll last = 0,n;
bool ask(ll i){
    ll cur = Query(i);
    bool ans = cur!=last;
    last = cur;
    return ans;
}
void reshi(vector<ll> l,vector<ll> r,bool f){
    n = sz(l);
    ll m = ceil(n*0.35);
    if(n==1){
        Answer(l[0],r[0]);
        return;
    }
    if(f) m = n-m;
    if(f){
        for(ll i = n-1;i>=m;i--) ask(l[i]);
    }else{
        for(ll i = 0;i<m;i++) ask(l[i]);
    }
    shuffle(all(r),rng);
    vector<ll> L,R;
    for(ll i = 0;i<n;i++){
        if(sz(L)==m) R.pb(r[i]);
        else if(sz(R)==n-m) L.pb(r[i]);
        else if(ask(r[i])) R.pb(r[i]);
        else L.pb(r[i]);
    }
    vector<ll> lL,lR;
    for(ll i = 0;i<m;i++) lL.pb(l[i]);
    for(ll i = m;i<n;i++) lR.pb(l[i]);
    reshi(lL,L,1);
    reshi(lR,R,0);
}
void Solve(int N) {
    n = N;
    vector<ll> l,r;
    for(ll i = 1;i<=2*n;i++){
        if(ask(i)) l.pb(i);
        else r.pb(i);
    }
    reshi(l,r,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...