Submission #921536

#TimeUsernameProblemLanguageResultExecution timeMemory
921536Alihan_8Crayfish scrivener (IOI12_scrivener)C++17
34 / 100
1032 ms229564 KiB
#include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() #define ar array #define pb push_back #define ln '\n' //#define int long long using i64 = long long; template <class F, class _S> bool chmin(F &u, const _S &v){ bool flag = false; if ( u > v ){ u = v; flag |= true; } return flag; } template <class F, class _S> bool chmax(F &u, const _S &v){ bool flag = false; if ( u < v ){ u = v; flag |= true; } return flag; } vector <vector<int>> a, s; vector <int> def; vector <char> t; void Init() { def.resize(21); a.pb(def), s.pb(def); t.pb('#'); } void TypeLetter(char L) { int i = (int)a.size(); a.pb(def), s.pb(def); a[i][0] = i - 1; s[i][0] = 1; for ( int j = 1; j <= 20; j++ ){ a[i][j] = a[a[i][j - 1]][j - 1]; s[i][j] = s[a[i][j - 1]][j - 1] + s[i][j - 1]; } t.pb(L); } void UndoCommands(int U) { int i = (int)a.size(); a.pb(def), s.pb(def); a[i][0] = i - U - 1; for ( int j = 1; j <= 20; j++ ){ a[i][j] = a[a[i][j - 1]][j - 1]; s[i][j] = s[a[i][j - 1]][j - 1] + s[i][j - 1]; } t.pb('-'); } char GetLetter(int P) { int i = (int)a.size() - 1; int tot = s[i][20] - 1; for ( int j = 20; j >= 0; j-- ){ if ( tot - s[i][j] >= P ){ tot -= s[i][j]; i = a[i][j]; } } return t[i]; }
#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...