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;
vector <int> def, d;
vector <char> t;
void Init() {
def.resize(21);
a.pb(def);
d.pb(0);
t.pb('#');
}
void TypeLetter(char L) {
int i = (int)a.size();
a.pb(def);
d.pb(d.back() + 1);
a[i][0] = i - 1;
for ( int j = 1; j <= 20; j++ ){
a[i][j] = a[a[i][j - 1]][j - 1];
} t.pb(L);
}
void UndoCommands(int U) {
int i = (int)a.size();
a.pb(def);
a[i][0] = i - U - 1;
d.pb(d[i - U - 1]);
for ( int j = 1; j <= 20; j++ ){
a[i][j] = a[a[i][j - 1]][j - 1];
} t.pb('-');
}
char GetLetter(int P) {
int i = (int)a.size() - 1;
for ( int j = 20; j >= 0; j-- ){
if ( d[a[i][j]] >= P + 1 ){
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... |