Submission #679990

#TimeUsernameProblemLanguageResultExecution timeMemory
679990Ahmed57Crayfish scrivener (IOI12_scrivener)C++14
5 / 100
628 ms179232 KiB
#include <bits/stdc++.h>

using namespace std;
//TRIE
struct node{
   node *nxt[26];
   int ind;
   node(){
      ind = -1;
      for(int i = 0;i<26;i++){
        nxt[i] = NULL;
      }
   }
};

map<int,node*> mp;
map<int,char> ch;
node* root = new node();
int op = 0;
void Init(){
    mp[op] = root;
}
void TypeLetter(char l){
    if(root->nxt[l-'a']==NULL){
        root->nxt[l-'a'] = new node();
    }
    int z = root->ind;
    root = root->nxt[l-'a'];
    root->ind = z+1;
    ch[z+1] = l;
    mp[++op] = root;
}
void UndoCommands(int u){
    mp[++op] = mp[op-(u+1)];
    root = mp[op];
}
char GetLetter(int p){
    return ch[p];
}
/*int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    init();
    TypeLetter('a');
    TypeLetter('b');
    cout<<GetLetter(1)<<"\n";
    TypeLetter('d');
    UndoCommands(2);
    UndoCommands(1);
    cout<<GetLetter(2)<<"\n";
}*/

Compilation message (stderr)

scrivener.cpp: In function 'void UndoCommands(int)':
scrivener.cpp:34:8: warning: operation on 'op' may be undefined [-Wsequence-point]
   34 |     mp[++op] = mp[op-(u+1)];
      |        ^~~~
#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...