# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
935888 | PagodePaiva | Crayfish scrivener (IOI12_scrivener) | C++17 | 1061 ms | 15780 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#pragma GCC optimize("03", "fast-math")
#define N 1000005
using namespace std;
int pai[N], h[N], jump[N], pos[N];
char letter[N];
int t;
void Init() {
t = 0;
}
void TypeLetter(char L) {
t++;
pai[t] = t-1;
h[t] = h[t-1] + 1;
letter[t] = L;
pos[t] = pos[t-1]+1;
int p = t-1;
if(h[jump[p]] - h[p] == h[jump[jump[p]]] - h[jump[p]]){
jump[t] = jump[jump[p]];
}
else{
jump[t] = p;
}
}
void UndoCommands(int U) {
t++;
pai[t] = t-U-1;
int p = pai[t];
h[t] = h[pai[t]] + 1;
letter[t] = letter[p];
pos[t] = pos[p];
if(h[jump[p]] = h[p] == h[jump[jump[p]]] - h[jump[p]]){
jump[t] = jump[jump[p]];
}
else{
jump[t] = p;
}
}
char GetLetter(int P) {
P++;
int v = t;
while(pos[v] > P){
if(pos[jump[v]] < P){
v = pai[v];
}
else{
v = jump[v];
}
}
return letter[v];
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |