Submission #680013

#TimeUsernameProblemLanguageResultExecution timeMemory
680013Ahmed57Crayfish scrivener (IOI12_scrivener)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>

using namespace std;
map<int,char> arr;
int len[100001];
int mp[100001];
int op = 0 , root = 0 , node = 0;
int lift[100001][20];
void Init(){
    mp[op] = root;
}
void TypeLetter(char l){
    node++;
    lift[node][0] = root;
    for(int i = 1;i<20;i++){
        lift[node][i] = lift[lift[node][i-1]][i-1];
    }
    len[node] = len[root]+1;
    root = node;
    op++;
    mp[op] = root;
    arr[root] = l;
}
void UndoCommands(int u){
    mp[op+1] = mp[op-u];
    root = mp[++op];
}
char GetLetter(int p){
    int cc = root;
    p = (p+1)-len[root];
    for(int i = 19;i>=0;i--){
        if(p>=(1<<i)){
            p-=(1<<i);
            cc =lift[cc][i];
        }
    }
    return arr[cc];
}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    Init();
    TypeLetter('a');
    cout<<root<<"\n";
    TypeLetter('b');
    cout<<root<<"\n";
    cout<<GetLetter(1)<<"\n";
    TypeLetter('d');
    cout<<root<<"\n";
    UndoCommands(2);
    cout<<root<<"\n";
    UndoCommands(1);
    cout<<root<<"\n";
    cout<<GetLetter(2)<<"\n";
    TypeLetter('e');
    UndoCommands(1);
    UndoCommands(5);
    TypeLetter('c');
    cout<<GetLetter(2)<<"\n";
    UndoCommands(2);
    cout<<GetLetter(2)<<"\n";
}

Compilation message (stderr)

/usr/bin/ld: /tmp/ccA0UKNm.o: in function `main':
scrivener.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cchidgYm.o:grader.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status