#include <bits/stdc++.h>
using namespace std;
#define type(x) __typeof((x).begin())
#define foreach(it, x) for(type(x) it = (x).begin(); it != (x).end(); it++)
typedef long long ll;
typedef pair < int, int > ii;
const int inf = 1e9 + 333;
const ll linf = 1e18 + inf;
const int N = 1e6 + 5;
const int LOG = 21;
void Init() {}
int x = 0;
int op[N], sm[N], lca[LOG][N];
void TypeLetter(char c) {
op[++x] = c;
sm[x] = sm[x - 1] + 1;
lca[0][x] = x - 1;
for(int i = 1; i < LOG; i++) {
lca[i][x] = lca[i - 1][lca[i - 1][x]];
}
}
void UndoCommands(int k) {
x++;
sm[x] = sm[x - 1];
lca[0][x] = x - 1 - k;
for(int i = 1; i < LOG; i++) {
lca[i][x] = lca[i - 1][lca[i - 1][x]];
}
}
char GetLetter(int p) {
int x1 = x;
for(int i = LOG - 1; i >= 0; i--) {
if(sm[lca[i][x1]] >= p + 1) {
x1 = lca[i][x1];
}
}
return op[x1];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
91556 KB |
Output is correct |
2 |
Correct |
0 ms |
91556 KB |
Output is correct |
3 |
Correct |
0 ms |
91556 KB |
Output is correct |
4 |
Correct |
0 ms |
91556 KB |
Output is correct |
5 |
Correct |
0 ms |
91556 KB |
Output is correct |
6 |
Correct |
0 ms |
91556 KB |
Output is correct |
7 |
Correct |
0 ms |
91556 KB |
Output is correct |
8 |
Correct |
0 ms |
91556 KB |
Output is correct |
9 |
Correct |
3 ms |
91556 KB |
Output is correct |
10 |
Correct |
0 ms |
91556 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
91556 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
91556 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
278 ms |
91556 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
474 ms |
91556 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |