# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
104261 | arman_ferdous | Crayfish scrivener (IOI12_scrivener) | C++14 | 699 ms | 87332 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 "grader.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6+10;
char c[N];
int lev[N];
int cur, freePtr;
int p[N][20], state[N], ptr;
void Init() {
lev[0] = -1;
memset(p,-1,sizeof p);
c[0] = '?';
cur = 0; freePtr = 1;
state[0] = cur; ptr = 0;
}
void TypeLetter(char L) {
int idx = freePtr++;
p[idx][0] = cur;
c[idx] = L, lev[idx] = lev[cur] + 1;
cur = idx;
for(int j = 1; j < 20; j++)
if(p[cur][j-1] + 1)
p[cur][j] = p[p[cur][j-1]][j-1];
state[++ptr] = cur;
}
void UndoCommands(int U) {
state[ptr+1] = state[max(0, ptr - U)];
ptr++;
cur = state[ptr];
}
char GetLetter(int P) {
int tmp = cur, need = lev[cur] - P;
for(int j = 19; j >= 0; j--)
if(need >= (1<<j)) {
need -= (1<<j);
cur = p[cur][j];
}
return c[cur];
}
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... |