#include <bits/stdc++.h>
#define fi first
#define se second
#define ryan bear
#define all(V) (V).begin(), (V).end()
#define unq(V) (V).erase(unique(all(V)), (V).end())
#define fastio ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
typedef long long ll;
typedef vector<ll> vlm;
typedef vector<int> vim;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
struct node {
char ch;
node *l, *r;
node() { ch=0; l=r=NULL; }
}*root[1000010];
int sz[1000010], tp;
void upd(node *now, node *nd, int t, int s, int e, char val) {
assert(now!=NULL);
if (s==e) { now->ch=val; return ; }
int md=(s+e)/2;
if (t<=md) {
now->l=new node();
now->r=(nd?nd->r:NULL);
upd(now->l, nd?nd->l:NULL, t, s, md, val);
}
else {
now->l=(nd?nd->l:NULL);
now->r=new node();
upd(now->r, nd?nd->r:NULL, t, md+1, e, val);
}
}
char get(node *now, int t, int s, int e) {
assert(now!=NULL);
if (s==e) return now->ch;
int md=(s+e)/2;
if (t<=md) return get(now->l, t, s, md);
else return get(now->r, t, md+1, e);
}
void Init() { root[0]=new node(); tp=1; memset(sz, 0, sizeof(sz)); }
void TypeLetter(char L) {
root[tp]=new node();
sz[tp]=sz[tp-1]+1;
upd(root[tp], root[tp-1], sz[tp], 1, 1000000, L);
tp++;
}
void UndoCommands(int U) { root[tp]=root[tp-U-1]; sz[tp]=sz[tp-U-1]; tp++; }
char GetLetter(int P) { return get(root[tp-1], P+1, 1, 1000000); }
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
4216 KB |
Output is correct |
2 |
Correct |
9 ms |
4344 KB |
Output is correct |
3 |
Correct |
5 ms |
4216 KB |
Output is correct |
4 |
Correct |
5 ms |
4216 KB |
Output is correct |
5 |
Correct |
6 ms |
4344 KB |
Output is correct |
6 |
Correct |
9 ms |
4344 KB |
Output is correct |
7 |
Correct |
5 ms |
4220 KB |
Output is correct |
8 |
Correct |
8 ms |
4344 KB |
Output is correct |
9 |
Correct |
1 ms |
4348 KB |
Output is correct |
10 |
Correct |
6 ms |
4216 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4216 KB |
Output is correct |
2 |
Correct |
6 ms |
4216 KB |
Output is correct |
3 |
Correct |
6 ms |
4344 KB |
Output is correct |
4 |
Correct |
0 ms |
4220 KB |
Output is correct |
5 |
Correct |
3 ms |
4188 KB |
Output is correct |
6 |
Correct |
5 ms |
4344 KB |
Output is correct |
7 |
Correct |
1 ms |
4344 KB |
Output is correct |
8 |
Correct |
5 ms |
4216 KB |
Output is correct |
9 |
Correct |
6 ms |
4216 KB |
Output is correct |
10 |
Correct |
5 ms |
4216 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
5240 KB |
Output is correct |
2 |
Correct |
9 ms |
5240 KB |
Output is correct |
3 |
Correct |
9 ms |
5368 KB |
Output is correct |
4 |
Correct |
9 ms |
6136 KB |
Output is correct |
5 |
Correct |
4 ms |
5372 KB |
Output is correct |
6 |
Correct |
14 ms |
6648 KB |
Output is correct |
7 |
Correct |
11 ms |
6648 KB |
Output is correct |
8 |
Correct |
9 ms |
6012 KB |
Output is correct |
9 |
Correct |
10 ms |
6136 KB |
Output is correct |
10 |
Correct |
10 ms |
5240 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
590 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
742 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |