Submission #1191843

#TimeUsernameProblemLanguageResultExecution timeMemory
1191843LolkasMeepCrayfish scrivener (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]=Try(L, tries[i-1]); i++; } void UndoCommands(int U){ tries[i]=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 TypeLetter(char)':
scrivener.cpp:34:14: error: cannot convert 'Try' to 'Try*' in assignment
   34 |     tries[i]=Try(L, tries[i-1]);
      |              ^~~~~~~~~~~~~~~~~~
      |              |
      |              Try
scrivener.cpp: In function 'void UndoCommands(int)':
scrivener.cpp:38:18: error: 'L' was not declared in this scope
   38 |     tries[i]=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 | }
      | ~