# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
935667 | tnun | Crayfish scrivener (IOI12_scrivener) | C++14 | 1 ms | 856 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;
#define pb push_back
struct node{
char c;
int p[20];
int h;
};
vector<node> trie;
const int N=1000003;
int cur[N];
int current=0;
int curs;
node Add(char L,int par){
node j;
j.h=trie[par].h+1;
j.p[0]=par;
j.c=L;
for(int i=1;i<20;i++){
j.p[i]=trie[j.p[i-1]].p[i-1];
}
return j;
}
void TypeLetter(char L){
cur[current]=trie.size();
trie.pb(Add(L,curs));
curs=cur[current];
current++;
}
void UndoCommands(int S){
cur[current]=cur[current-S+1];
curs=cur[current];
current++;
}
char GetLetter(int idx){
idx++;
int v=curs;
for(int i=19;i>=0;i--){
if(trie[trie[v].p[i]].h >= idx){
v=trie[v].p[i];
}
}
return trie[v].c;
}
void Init(){
node first;
first.c=0;
for(int i=0;i<20;i++){
first.p[i]=0;
}
first.h=0;
}
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... |