int rear,cnt;
int par[1000010][22];
int next[1000010];
char a[1000010];
void Init(){
rear = cnt = 0;
}
void TypeLetter(char L) {
int i;
rear++; cnt++;
next[cnt] = rear;
a[rear] = L;
par[rear][0] = next[rear-1];
for(i=1; i<=19; i++){
par[rear][i] = par[par[rear][i-1]][i-1];
}
}
void UndoCommands(int U) {
cnt++;
next[cnt] = next[cnt-U];
}
char GetLetter(int P) {
int i,x;
int ans;
ans = rear;
x = next[cnt]-(P+1);
for(i=19; i>=0; i--){
if(x == 0) break;
if(x >= (1 << i)){
x -= (1 << i);
ans -= (1 << i);
}
}
return a[ans];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
91896 KB |
Output is correct |
2 |
Correct |
0 ms |
91896 KB |
Output is correct |
3 |
Correct |
0 ms |
91896 KB |
Output is correct |
4 |
Correct |
0 ms |
91896 KB |
Output is correct |
5 |
Correct |
0 ms |
91896 KB |
Output is correct |
6 |
Correct |
0 ms |
91896 KB |
Output is correct |
7 |
Correct |
0 ms |
91896 KB |
Output is correct |
8 |
Correct |
0 ms |
91896 KB |
Output is correct |
9 |
Correct |
0 ms |
91896 KB |
Output is correct |
10 |
Correct |
0 ms |
91896 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
91896 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
91896 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
269 ms |
91896 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
299 ms |
91896 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |