Submission #940925

#TimeUsernameProblemLanguageResultExecution timeMemory
940925Tuanlinh123Toxic Gene (NOI23_toxic)C++17
14.77 / 100
8 ms600 KiB
#include "toxic.h" #include<bits/stdc++.h> #define ll int #define pll pair<ll, ll> #define pb push_back #define mp make_pair #define fi first #define se second #define ld long double #define sz(a) ((ll)(a).size()) using namespace std; mt19937_64 rng(170306); void determine_type(ll n) { ll lo=1, hi=n; auto queryrange=[&](ll l, ll r) { vector <ll> ask(r-l+1); iota(ask.begin(), ask.end(), l); return query_sample(ask); }; while (hi>lo) { ll mid=(lo+hi)/2; if (queryrange(lo, mid)==mid-lo+1) lo=mid+1; else hi=mid; } vector <char> ans(n+1, 0); ans[lo]='T'; for (ll i=1; i<=n; i+=8) { vector <ll> ask; ask.pb(lo); for (ll j=i; j<=n && j<i+8; j++) for (ll k=0; k<1<<(j-i); k++) ask.pb(j); ll x=query_sample(ask); for (ll j=i; j<=n && j<i+8; j++) if (x&1<<(j-i)) ans[j]='S'; } vector <ll> idx; for (ll i=1; i<=n; i++) if (!ans[i]) idx.pb(i); shuffle(idx.begin(), idx.end(), rng); auto queryran=[&](ll l, ll r) { vector <ll> ask; for (ll i=l; i<r; i++) ask.pb(idx[i]); return query_sample(ask); }; ll len=max(1, sz(idx)/30); for (ll i=0; i<sz(idx); i+=len) { ll x=queryran(i, min(sz(idx), i+len)); if (x) { for (ll j=i; j<min(sz(idx), i+len); j++) ans[idx[j]]='R'; } else if (min(sz(idx), i+len)-i==1) ans[idx[i]]='T'; else { for (ll j=i; j<min(sz(idx), i+len); j++) { if (queryran(j, j+1)) ans[idx[j]]='R'; else ans[idx[j]]='T'; } } } for (ll i=1; i<=n; i++) answer_type(i, ans[i]); }
#Verdict Execution timeMemoryGrader output
Fetching results...