This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
int NodeNum, Anc[1000001][30], OrderNum, Order[1000001], Lev[1000001];
char A[1000001];
void Init(void)
{
}
void TypeLetter(char L)
{
int i;
NodeNum++;
A[NodeNum]=L;
Anc[NodeNum][0]=Order[OrderNum];
Lev[NodeNum]=Lev[Order[OrderNum]]+1;
i=1;
while(Anc[Anc[NodeNum][i-1]][i-1])
{
Anc[NodeNum][i]=Anc[Anc[NodeNum][i-1]][i-1];
i++;
}
OrderNum++;
Order[OrderNum]=NodeNum;
}
void UndoCommands(int U)
{
OrderNum++;
Order[OrderNum]=Order[OrderNum-U-1];
}
char GetLetter(int P)
{
int N, Now, Cnt=0;
N=Lev[Order[OrderNum]]-P-1;
Now=Order[OrderNum];
while(N)
{
if(N&1)
Now=Anc[Now][Cnt];
Cnt++;
N>>=1;
}
return A[Now];
}
# | 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... |