#include <iostream>
using namespace std;
char last;
int vis[1000005][2],loc,l[10000005],r[10000005],cnt,v;
char val,tree[10000005];
void Init(){
vis[0][0]=0;
vis[0][1]=0;
}
void clone(int a,int b)
{
l[b]=l[a];
r[b]=r[a];
tree[b]=tree[a];
return ;
}
int change(int node,int s,int e)
{
//cout<<s<<" "<<e<<endl;
cnt++;
clone(node,cnt);
if(s==e)
{
tree[cnt]=val;
return cnt;
}
long long int now=cnt;
if(vis[v][1]<=(s+e)/2)
{
l[now]=change(l[now],s,(s+e)/2);
}
else r[now]=change(r[now],(s+e)/2+1,e);
return now;
}
char find(int node,int s,int e){
if(s==e)return tree[node];
if(loc<=(s+e)/2)return find(l[node],s,(s+e)/2);
else return find(r[node],(s+e)/2+1,e);
}
void TypeLetter(char L) {
v++;
val=L;
vis[v][0]=cnt+1;
vis[v][1]=vis[v-1][1]+1;
change(vis[v-1][0],1,1000000);
}
void UndoCommands(int U) {
v++;
vis[v][0]=vis[v-U-1][0];
vis[v][1]=vis[v-U-1][1];
return ;
}
char GetLetter(int P) {
loc=P+1;
return find(vis[v][0],1,1000000);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
640 KB |
Output is correct |
2 |
Correct |
2 ms |
640 KB |
Output is correct |
3 |
Correct |
2 ms |
772 KB |
Output is correct |
4 |
Correct |
2 ms |
896 KB |
Output is correct |
5 |
Correct |
2 ms |
768 KB |
Output is correct |
6 |
Correct |
3 ms |
1152 KB |
Output is correct |
7 |
Correct |
2 ms |
1024 KB |
Output is correct |
8 |
Correct |
2 ms |
896 KB |
Output is correct |
9 |
Correct |
2 ms |
896 KB |
Output is correct |
10 |
Correct |
2 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
328 ms |
191020 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
530 ms |
194076 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |