이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
int const nmax = 1000000;
char last;
int const lgmax = 20;
int far[1 + nmax][1 + lgmax], ptr = 0;
int level[1 + nmax];
char chr[1 + nmax];
void Init() {}
void TypeLetter(char L) {
++ptr;
far[ptr][0] = ptr - 1;
for(int h = 1; h < lgmax; h++)
far[ptr][h] = far[far[ptr][h - 1]][h - 1];
level[ptr] = level[far[ptr][0]] + 1;
chr[ptr] = L;
}
void UndoCommands(int U) {
++ptr;
far[ptr][0] = ptr - 1 - U;
for(int h = 1; h < lgmax; h++)
far[ptr][h] = far[far[ptr][h - 1]][h - 1];
level[ptr] = level[far[ptr][0]];
}
char GetLetter(int P) {
int pos = ptr;
P++;
for(int h = lgmax - 1; 0 <= h; h--)
if(P <= level[far[pos][h]] )
pos = far[pos][h];
return chr[pos];
}
# | 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... |