# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
820150 | BT21tata | Crayfish scrivener (IOI12_scrivener) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int que, up[1000006][21], len[1000006];
char c[1000006];
void Init() {}
void TypeLetter(char L)
{
que++;
c[que]=L;
up[que][0]=que-1;
len[que]=len[que-1]+1;
for(int i=1; i<21; i++)
up[que][i]=up[up[que][i-1]][i-1];
}
void UndoCommands(int U)
{
que++;
len[que]=len[que-1-U];
c[que]=c[que-1-U]
for(int i=0; i<21; i++)
up[que][i]=up[que-1-U][i];
}
char GetLetter(int p)
{
p=len[que]-1-p;
int cur=que;
for(int i=20; i>=0; i--)
{
if(p-(1<<i)>=0)
{
p-=(1<<i);
cur=up[cur][i];
}
}
return c[cur];
}