#include <bits/stdc++.h>
using namespace std;
typedef int64_t llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
//#define endl '\n'
int ind[1000001];
int back[1000001];
int st[1000001];
int cc[1000001];
int co=1;
int cur[1000001][20];
char cop[1000001];
/*int find(int no){
if(st[no]==1){
return no;
}
par[no]=find(par[no]);
return no;
}*/
void Init() {
/*for(int j=0;j<20;j++){
cur[j][0]=-1;
}*/
//memset(cur,-1,sizeof(cur));
}
void TypeLetter(char L) {
cop[co]=L;
if(co>0){
ind[co]=back[co-1];
cc[co]=1+cc[ind[co]];
cur[co][0]=ind[co];
for(int j=1;j<20;j++){
if(cur[co][j-1]==-1){
break;
}
cur[co][j]=cur[cur[co][j-1]][j-1];
}
}
else{
cc[co]=1;
}
back[co]=co;
co+=1;
}
void UndoCommands(int u) {
back[co]=back[co-u-1];
//cout<<co<<","<<back[co-u]<<endl;
co+=1;
}
char GetLetter(int p) {
int la=back[co-1];
if(p==cc[la]-1){
// cout<<cop[la]<<endl;
return cop[la];
}
int jj=la;
int x=la-cc[la]-1;
for(int j=19;j>=0;j--){
if(x&(1<<j)){
jj=cur[jj][j];
}
}
//cout<<cop[jj]<<endl;
return cop[jj];
}
/*
14
T a
T b
P 1
T d
U 2
U 1
P 2
T e
U 1
U 5
T c
P 2
U 2
P 2
*/
/*
g++ -DEVAL -Wall -static -O2 -o aa grader1.cpp scrivener.cpp
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
512 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
369 ms |
65496 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
414 ms |
60168 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |