# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
261003 | georgerapeanu | Crayfish scrivener (IOI12_scrivener) | C++11 | 824 ms | 94972 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.
#pragma once
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
const int NMAX = 1e6;
const int LGMAX = 21;
vector< vector<int> > father;
vector<int> lvl;
vector<int> active_node;
vector<char> c;
int create_new_node(int tata,char l){
int node = (int)father.size();
father.push_back(vector<int>(LGMAX,0));
c.push_back(l);
father.back()[0] = tata;
lvl.push_back(1 + lvl[tata]);
for(int i = 1;i < LGMAX;i++){
father.back()[i] = father[father.back()[i - 1]][i - 1];
}
return node;
}
void Init() {
father.push_back(vector<int>(LGMAX,0));
active_node.push_back(0);
lvl.push_back(0);
c.push_back('0');
}
void TypeLetter(char L) {
active_node.push_back(create_new_node(active_node.back(),L));
}
void UndoCommands(int U) {
active_node.push_back(active_node[(int)active_node.size() - 1 - U]);
}
char GetLetter(int P) {
P++;
int node = active_node.back();
P = lvl[node] - P;
for(int i = LGMAX - 1;i >= 0;i--){
if((P >> i) & 1){
node = father[node][i];
P ^= (1 << i);
}
}
return c[node];
}
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... |