This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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(20);
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 <= 19; 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 <= 19; 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][19] - 1;
for ( int j = 19; j >= 0; j-- ){
if ( tot - s[i][j] >= P ){
tot -= s[i][j];
i = a[i][j];
}
}
return t[i];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |