const int lgMAXN = 20;
const int MAXN = 1 << 20;
int len;
int arr[MAXN];
int sparse[MAXN][lgMAXN];
void Init() {
len = 0;
}
void TypeLetter(char L) {
arr[++len] = L;
sparse[len][0] = len;
for(int i=1; i<lgMAXN; ++i)
sparse[len][i] = sparse[sparse[len][i-1]-1][i-1];
}
void UndoCommands(int U) {
arr[++len] = -U;
for(int i=0; i<lgMAXN; ++i)
sparse[len][i] = sparse[len-U-1][i];
}
char GetLetter(int P) {
int c = 0, idx = len;
for(int i=lgMAXN-1; i>=0; --i)
if(sparse[idx][i])
{
c += (1<<i);
idx = sparse[idx][i]-1;
}
int ans = len;
for(int i=lgMAXN-1; i>=0; --i)
if((c-P)&(1<<i))
ans = sparse[ans][i]-1;
return arr[ans+1];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4 ms |
376 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
5 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
5 ms |
724 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
5 ms |
1056 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
5 ms |
1076 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |