# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
234499 | nafis_shifat | Crayfish scrivener (IOI12_scrivener) | C++14 | 446 ms | 140024 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>
using namespace std;
const int mxn=1e6+6;
int tree[mxn][26];
int pos[mxn];
int pt=0;
int idx=0;
int dp[20][mxn]={};
int con[mxn];
int len[mxn];
void Init() {
len[0]=0;
pos[0]=0;
}
int climb(int p,int k) {
for(int i=0;i<20;i++) {
if(k>>i & 1)p=dp[i][p];
}
return p;
}
void TypeLetter(char L) {
L-='a';
int lp=pos[pt];
if(tree[lp][L]) {
pos[++pt]=tree[lp][L];
} else {
tree[lp][L]=++idx;
pos[++pt]=tree[lp][L];
con[idx]=L;
dp[0][idx]=lp;
len[idx]=len[lp]+1;
for(int i=1;i<20;i++) {
dp[i][idx]=dp[i-1][dp[i-1][idx]];
}
}
}
void UndoCommands(int u) {
pos[pt+1]=pos[pt - u];
pt++;
}
char GetLetter(int p) {
p++;
int c=len[pos[pt]];
char r='a' + (con[climb(pos[pt],c-p)]);
return r;
}
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... |