이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
const int M=1000010;
char letter[M]; /// access by state
int depth[M]; /// access by state
int parent[M][21]; /// access by state
int state[M]; /// access by command
int coms, stats;
void Init(){
}
void TypeLetter(char x){
coms++; stats++;
state[coms ]=stats;
letter[stats]=x;
int myp = state[coms-1];
parent[stats][0]=myp;
depth[stats]=depth[myp]+1;
int i;
for(i=1;i<=20;i++){
parent[stats][i]=parent[parent[stats][i-1]][i-1];
}
}
void UndoCommands(int x){
coms++;
state[coms]=state[coms-1-x];
}
char GetLetter(int pos){
int cur=state[coms];
pos = depth[cur]-pos-1;
int i;
for(i=0;i<=20;i++){
if(pos&(1<<i)){
cur = parent[cur][i];
}
}
return letter[cur];
}
# | 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... |