#include <bits/stdc++.h>
using namespace std;
const int MAXN=1e6+3;
const int LOGN=22;
int cont[MAXN], letra[MAXN];
int dp[MAXN][LOGN+3];
int contv=0;
void update(int cur) {
int aux=dp[cur][0];
for(int i=1; i<=LOGN; i++) {
dp[cur][i]=dp[aux][i-1];
aux=dp[cur][i];
}
}
void Init() {}
void TypeLetter(char cur) {
contv++; int pai=contv-1;
if(pai==0) pai=contv;
letra[contv]=cur;
cont[contv]=cont[pai]+1;
dp[contv][0]=pai;
update(contv);
}
void UndoCommands(int val) {
contv++; int pai=contv-1-val;
if(pai==0) pai=contv;
cont[contv]=cont[pai];
dp[contv][0]=pai;
update(contv);
}
char GetLetter(int ind) {
int cur=contv;
int aux=cur;
while(aux!=dp[aux][0]&&cont[dp[aux][0]]!=ind) aux=dp[aux][0];
return letra[aux];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
512 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
512 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
512 KB |
Output is correct |
2 |
Correct |
5 ms |
640 KB |
Output is correct |
3 |
Correct |
3 ms |
768 KB |
Output is correct |
4 |
Correct |
3 ms |
768 KB |
Output is correct |
5 |
Correct |
4 ms |
768 KB |
Output is correct |
6 |
Correct |
4 ms |
768 KB |
Output is correct |
7 |
Correct |
4 ms |
768 KB |
Output is correct |
8 |
Correct |
6 ms |
768 KB |
Output is correct |
9 |
Correct |
8 ms |
768 KB |
Output is correct |
10 |
Correct |
4 ms |
896 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1071 ms |
75832 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1070 ms |
9344 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |