이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <vector>
using namespace std;
struct node {
char letter;
int ancestors[20];
int depth;
};
node history[1000001];
int moves = 0;
void Init() {
history[0].depth = 0;
for (int i=0; i<1000001; i++) {
for (int j=0; j<20; j++) history[i].ancestors[j] = -1;
}
}
void TypeLetter(char L) {
moves++;
history[moves].letter = L;
history[moves].depth = history[moves-1].depth+1;
history[moves].ancestors[0] = moves-1;
for (int i=1; i<20; i++) {
if (history[history[moves].ancestors[i-1]].ancestors[i-1] == -1) break;
history[moves].ancestors[i] = history[history[moves].ancestors[i-1]].ancestors[i-1];
}
}
void UndoCommands(int U) {
moves++;
history[moves] = history[moves-U-1];
}
char GetLetter(int P) {
node ans = history[moves];
for (int i=0; i<20; i++) {
if ((history[moves].depth-P-1)&(1<<i)) ans = history[ans.ancestors[i]];
}
return ans.letter;
}
# | 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... |