제출 #679989

#제출 시각아이디문제언어결과실행 시간메모리
679989Ahmed57Crayfish scrivener (IOI12_scrivener)C++14
컴파일 에러
0 ms0 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";
}*/

컴파일 시 표준 에러 (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)];
      |        ^~~~
/usr/bin/ld: /tmp/ccWPfLRE.o: in function `main':
grader.cpp:(.text.startup+0x63): undefined reference to `Init()'
collect2: error: ld returned 1 exit status