Submission #1191846

#TimeUsernameProblemLanguageResultExecution timeMemory
1191846LolkasMeep크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++20
0 / 100
1097 ms171040 KiB
#include "bits/stdc++.h"
using namespace std;

struct Try{
    Try* parent = NULL;
    Try *children[26] = {NULL};
    char chr;

    Try(char c, Try* p){
        parent = p;
        chr = c;
    }

    Try* add(char c){
        if(children[c-'a'] != NULL) return children[c-'a'];

        children[c-'a'] = new Try(c, this);

        return children[c-'a'];
    }

    string get(){
        if(parent == NULL) return ""+chr;
        return parent->get() + chr;
    }
};

int i=1;
Try *tries[1000005];
void Init(){
    tries[0] = NULL;
};
void TypeLetter(char L){
    tries[i]=new Try(L, tries[i-1]);
    i++;
}
void UndoCommands(int U){
    tries[i]=tries[i-U-1];
    i++;
}
char GetLetter(int P){
    return tries[i-1]->get()[P];
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...