This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define pb push_back
#define ss second
#define ff first
#define vt vector
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int inf = 1e9;
const int mod = 1e9+7;
const int maxn = 1e6 + 1;
char last;
int cnt, ope[maxn][20], wt[maxn], sz[maxn];
void Init() {
wt[0] = -1;
for(int j = 0; j < 20; j++)ope[0][j] = 0;
cnt = 1;
}
void TypeLetter(char L) {
sz[cnt] = sz[cnt - 1] + 1;
wt[cnt] = int(L - 'a');
ope[cnt][0] = cnt;
ope[cnt][1] = ope[cnt - 1][0];
for(int j = 2; j < 20; j++){
ope[cnt][j] = ope[ope[cnt][j - 1]][j - 1];
}
cnt++;
}
void UndoCommands(int U) {
U++;
for(int j = 0; j < 20; j++)ope[cnt][j] = ope[cnt - U][j];
wt[cnt] = -2;
sz[cnt] = sz[cnt - U];
cnt++;
}
char GetLetter(int P) {
int x = ope[cnt - 1][0];
P = sz[x] - P - 1;
for(int j = 18; j >= 0; j--){
if(P & (1 << j))x = ope[x][j + 1];
}
return char('a' + wt[x]);
}
//#define inbuf_len 1 << 16
//#define outbuf_len 1 << 16
//void solve() {
//Init();
//int cmd_num;
//int tmp = scanf("%d", &cmd_num);
//int i;
//for (i = 0; i < cmd_num; i++) {
//char cmd;
//tmp = scanf(" %c", &cmd);
//if (cmd == 'T') {
//char letter;
//tmp = scanf(" %c", &letter);
//assert(tmp == 1);
//TypeLetter(letter);
//}
//else if (cmd == 'U') {
//int number;
//tmp = scanf("%d", &number);
//assert(tmp == 1);
//UndoCommands(number);
//}
//else if (cmd == 'P') {
//int index;
//char letter;
//tmp = scanf("%d", &index);
//assert(tmp == 1);
//letter = GetLetter(index);
//printf("%c\n", letter);
//}
//}
//puts("Let's test for cheating!!");
//}
//int main() {
//ios_base::sync_with_stdio(0);
//cin.tie(0);
//int times = 1;
////cin >> times;
//for(int i = 1; i <= times; i++) {
//solve();
//}
//return 0;
//}
# | 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... |