#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <iomanip>
#include <deque>
#include <cassert>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <chrono>
#include <ctime>
#include <random>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <iterator>
#include <climits>
//#include "scrivener.h"
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
#define INF 2001001001
#define MOD 1000000007
int nex;
int length[1000001];
char c[1000001];
int anc[1000001][20];
bool started=false;
int LOG[1000001];
void calcAnc(int ind){
for (int i=1;i<=LOG[length[ind]];i++){
if (anc[ind][i-1]==-1 || i-1>LOG[length[anc[ind][i-1]]])
anc[ind][i]=-1;
else
anc[ind][i]=anc[anc[ind][i-1]][i-1];
}
}
void Init(){
anc[0][0]=-1;
for (int i=0;i<20;i++)
LOG[1<<i]=i;
for (int i=1;i<=1000000;i++)
if (LOG[i]==0)
LOG[i]=LOG[i-1];
}
void TypeLetter(char ch){
if (!started){
c[0]=ch;
length[0]=1;
nex++;
started=true;
return;
}
length[nex]=length[nex-1]+1;
c[nex]=ch;
anc[nex][0]=nex-1;
calcAnc(nex);
nex++;
}
void UndoCommands(int x){
length[nex]=length[nex-x-1];
c[nex]=c[nex-x-1];
anc[nex][0]=anc[nex-x-1][0];
calcAnc(nex);
nex++;
}
char GetLetter(int ind){
ind=length[nex-1]-1-ind;
int cur=nex-1;
for (int i=LOG[length[cur]];i>=0;i--){
if (((1<<i)&ind)!=0)
cur=anc[cur][i];
}
return c[cur];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
4216 KB |
Output is correct |
2 |
Correct |
9 ms |
4344 KB |
Output is correct |
3 |
Correct |
9 ms |
4216 KB |
Output is correct |
4 |
Correct |
9 ms |
4216 KB |
Output is correct |
5 |
Correct |
14 ms |
4216 KB |
Output is correct |
6 |
Correct |
10 ms |
4216 KB |
Output is correct |
7 |
Correct |
9 ms |
4216 KB |
Output is correct |
8 |
Correct |
9 ms |
4216 KB |
Output is correct |
9 |
Correct |
9 ms |
4220 KB |
Output is correct |
10 |
Correct |
9 ms |
4216 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
4216 KB |
Output is correct |
2 |
Correct |
9 ms |
4316 KB |
Output is correct |
3 |
Correct |
9 ms |
4344 KB |
Output is correct |
4 |
Correct |
9 ms |
4216 KB |
Output is correct |
5 |
Correct |
9 ms |
4220 KB |
Output is correct |
6 |
Correct |
9 ms |
4216 KB |
Output is correct |
7 |
Correct |
9 ms |
4216 KB |
Output is correct |
8 |
Correct |
9 ms |
4216 KB |
Output is correct |
9 |
Correct |
9 ms |
4216 KB |
Output is correct |
10 |
Correct |
9 ms |
4344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
4472 KB |
Output is correct |
2 |
Correct |
12 ms |
4472 KB |
Output is correct |
3 |
Correct |
10 ms |
4664 KB |
Output is correct |
4 |
Correct |
12 ms |
4600 KB |
Output is correct |
5 |
Correct |
11 ms |
4600 KB |
Output is correct |
6 |
Correct |
12 ms |
4600 KB |
Output is correct |
7 |
Correct |
8 ms |
4600 KB |
Output is correct |
8 |
Correct |
10 ms |
4636 KB |
Output is correct |
9 |
Correct |
10 ms |
4600 KB |
Output is correct |
10 |
Correct |
15 ms |
4728 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
616 ms |
65948 KB |
Output is correct |
2 |
Correct |
954 ms |
81228 KB |
Output is correct |
3 |
Correct |
568 ms |
80584 KB |
Output is correct |
4 |
Correct |
584 ms |
81048 KB |
Output is correct |
5 |
Correct |
577 ms |
75900 KB |
Output is correct |
6 |
Correct |
481 ms |
87288 KB |
Output is correct |
7 |
Correct |
971 ms |
77580 KB |
Output is correct |
8 |
Execution timed out |
1010 ms |
85620 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
691 ms |
62696 KB |
Output is correct |
2 |
Correct |
701 ms |
52472 KB |
Output is correct |
3 |
Correct |
459 ms |
65388 KB |
Output is correct |
4 |
Correct |
486 ms |
57436 KB |
Output is correct |
5 |
Correct |
510 ms |
78804 KB |
Output is correct |
6 |
Correct |
573 ms |
81284 KB |
Output is correct |
7 |
Correct |
593 ms |
81024 KB |
Output is correct |
8 |
Execution timed out |
1050 ms |
65784 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |