Submission #1106959

#TimeUsernameProblemLanguageResultExecution timeMemory
1106959rahidilbayramliCrayfish scrivener (IOI12_scrivener)C++17
100 / 100
309 ms188592 KiB
#pragma GCC optimize("-O3") #include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> #define ll long long #define ld long double #define vl vector<ll> #define vi vector<int> #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define f first #define s second #define pii pair<int, int> #define pll pair<ll, ll> #define pb push_back #define p_b pop_back using namespace std; using namespace __gnu_pbds; typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); const ll sz = 1e6+5; vl ord; ll n = 0; char val[sz]; ll p[23][sz], lev[sz]; void Init() { ord.pb(0); } void TypeLetter(char L) { val[++n] = L; lev[n] = lev[ord.back()] + 1; p[0][n] = ord.back(); ord.pb(n); for(ll i = 1; i < 22; i++) p[i][n] = p[i-1][p[i-1][n]]; } void UndoCommands(int U) { ll f = (ll)(ord.size()) - U - 1; ord.pb(ord[f]); } ll jump(ll x, ll k) { for(ll i = 21; i >= 0; i--) { if((k >> i) & 1) x = p[i][x]; } return x; } char GetLetter(int P) { ll k = lev[ord.back()] - P - 1; ll f = jump(ord.back(), k); return val[f]; }
#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...