#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];
vector<int> anc[1000001];
bool started=false;
void calcAnc(int ind){
for (int i=1;i<=19;i++){
if (anc[ind][i-1]==-1)
anc[ind][i]=-1;
else
anc[ind][i]=anc[anc[ind][i-1]][i-1];
}
}
void Init(){
for (int i=0;i<=1000000;i++)
for (int j=0;j<20;j++)
anc[i].push_back(0);
for (int i=0;i<20;i++)
anc[0][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=19;i>=0;i--){
if (((1<<i)&ind)!=0)
cur=anc[cur][i];
}
return c[cur];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
574 ms |
164716 KB |
Output is correct |
2 |
Correct |
539 ms |
164748 KB |
Output is correct |
3 |
Correct |
541 ms |
164744 KB |
Output is correct |
4 |
Correct |
576 ms |
164748 KB |
Output is correct |
5 |
Correct |
554 ms |
164728 KB |
Output is correct |
6 |
Correct |
532 ms |
164684 KB |
Output is correct |
7 |
Correct |
536 ms |
164896 KB |
Output is correct |
8 |
Correct |
533 ms |
164696 KB |
Output is correct |
9 |
Correct |
539 ms |
164768 KB |
Output is correct |
10 |
Correct |
542 ms |
164984 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
553 ms |
164916 KB |
Output is correct |
2 |
Correct |
535 ms |
164720 KB |
Output is correct |
3 |
Correct |
584 ms |
164744 KB |
Output is correct |
4 |
Correct |
535 ms |
164788 KB |
Output is correct |
5 |
Correct |
528 ms |
164748 KB |
Output is correct |
6 |
Correct |
543 ms |
164856 KB |
Output is correct |
7 |
Correct |
586 ms |
164768 KB |
Output is correct |
8 |
Correct |
539 ms |
164872 KB |
Output is correct |
9 |
Correct |
538 ms |
164740 KB |
Output is correct |
10 |
Correct |
633 ms |
164780 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
537 ms |
164716 KB |
Output is correct |
2 |
Correct |
535 ms |
164856 KB |
Output is correct |
3 |
Correct |
538 ms |
164940 KB |
Output is correct |
4 |
Correct |
539 ms |
164856 KB |
Output is correct |
5 |
Correct |
547 ms |
164964 KB |
Output is correct |
6 |
Correct |
539 ms |
164888 KB |
Output is correct |
7 |
Correct |
529 ms |
164800 KB |
Output is correct |
8 |
Correct |
539 ms |
164856 KB |
Output is correct |
9 |
Correct |
534 ms |
164728 KB |
Output is correct |
10 |
Correct |
528 ms |
164988 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1097 ms |
169728 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1090 ms |
170024 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |