//#include "grader.cpp"
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6+5;
struct A
{
int l,r;
char C;
};
A sm[N*30];
int root[N];
int cur;
int n;
int len[N];
int opr;
int clone(int idx) {sm[++cur] = sm[idx];return cur;}
int update(int l,int r,int idx,int now,char v)
{
int newnode = clone(now);
if(l==r)
{
sm[newnode].C = v;
return newnode;
}
int mid = (l+r) >> 1;
sm[newnode].r = update(mid+1,r,idx,sm[newnode].r,v);
return newnode;
}
char query(int l,int r,int now,int idx)
{
if(l==r) return sm[now].C;
int mid = (l+r) >> 1;
if(idx<=mid) return query(l,mid,sm[now].l,idx);
return query(mid+1,r,sm[now].r,idx);
}
void Init() {}
void TypeLetter(char L) {
++n;
len[++opr] = n;
root[opr] = update(0,n-1,n-1,root[opr-1],L);
}
void UndoCommands(int U) {
n = len[max(0,opr-U-1)];
len[++opr] = n;
root[opr] = root[max(0,opr-U-1)];
}
char GetLetter(int P) {
return query(0,n-1,root[opr],P);
}
/*int main()
{
while(1)
{
int cmd,U,P;
char L;
scanf("%d",&cmd);
if(cmd==1) scanf(" %c",&L),TypeLetter(L);
else if(cmd==2) scanf("%d",&U),UndoCommands(U);
else scanf("%d",&P),printf("%c\n",GetLetter(P));
}
}*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
512 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
266 ms |
114808 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
288 ms |
97596 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |