Submission #1191844

#TimeUsernameProblemLanguageResultExecution timeMemory
1191844LolkasMeep크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++20
Compilation error
0 ms0 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]=new Try(L, tries[i-U-1]);
    i++;
}
char GetLetter(int P){
    return tries[i-1]->get()[P]
}

Compilation message (stderr)

scrivener.cpp:26:2: error: expected ';' after struct definition
   26 | }
      |  ^
      |  ;
scrivener.cpp: In member function 'std::string Try::get()':
scrivener.cpp:23:35: error: could not convert '((Try*)this)->Try::chr' from 'char' to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   23 |         if(parent == NULL) return chr;
      |                                   ^~~
      |                                   |
      |                                   char
scrivener.cpp: In function 'void UndoCommands(int)':
scrivener.cpp:38:22: error: 'L' was not declared in this scope
   38 |     tries[i]=new Try(L, tries[i-U-1]);
      |                      ^
scrivener.cpp: In function 'char GetLetter(int)':
scrivener.cpp:42:32: error: expected ';' before '}' token
   42 |     return tries[i-1]->get()[P]
      |                                ^
      |                                ;
   43 | }
      | ~