# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1232990 | dssfsuper2 | Crayfish scrivener (IOI12_scrivener) | C++20 | 1098 ms | 119008 KiB |
#include <bits/stdc++.h>
using namespace std;
struct state{
int curl;
char curc;
vector<int> bl;
};
vector<state> states;
state cs;
state null;
void Init() {
cs.curl=-1;
cs.curc=' ';
cs.bl={};
states.push_back(cs);
for(int i = 0;i<22;i++){
states.back().bl.push_back(0);
}
}
void TypeLetter(char L) {
state x;
x.curl=cs.curl+1;
x.curc=L;
//to generate parents: first take previous, then take his first bl, then take the 2nd bl of his, etc
//x.par=&states[states.size()-1];
auto temp = states[states.size()-1];
x.bl={(int)states.size()-1};
for(int i = 0;i<21;i++){
x.bl.push_back((temp.bl[i]));
temp=states[temp.bl[i]];
}
states.push_back(x);
cs=x;
}
void UndoCommands(int U) {
state x;
x.curl=states[states.size()-U-1].curl;
x.curc=states[states.size()-U-1].curc;
auto temp = states[states.size()-U-1];
x.bl={(int)states.size()-U-1};
for(int i = 0;i<21;i++){
x.bl.push_back(temp.bl[i]);
temp=states[temp.bl[i]];
}
states.push_back(x);
cs=states.back();
}
char GetLetter(int P) {
state tmp=cs;
if(cs.curl==P){
return cs.curc;
}
for(int i = 21;i>=0;i--){
if(states[tmp.bl[i]].curl>P)tmp=states[tmp.bl[i]];
else if (states[tmp.bl[i]].curl==P)return states[tmp.bl[i]].curc;
}
}
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... |