Submission #208250

# Submission time Handle Problem Language Result Execution time Memory
208250 2020-03-10T12:40:34 Z DodgeBallMan Crayfish scrivener (IOI12_scrivener) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 1e6 + 10;
struct node {
    char d;
    int sz;
    node* par[20];
    node() { }
    node( char d ) : d( d ) { for( int i = 0 ; i <= 19 ; i++ ) par[i] = nullptr; }
}

int ptr;
node* s[N];

void Init() {
    ptr = 0;
    s[0] = null;
}
void TypeLetter( char a ) {
    ++ptr;
    s[ptr] = new node( a );
    s[ptr]->sz = s[ptr-1]->sz ? s[ptr-1]->sz + 1 : 1;
    s[ptr]->par[0] = s[ptr-1];
    for( int i = 1 ; i <= 19 ; i++ ) if( s[ptr]->par[i-1] )
        s[ptr]->par[i] = s[ptr]->par[i-1]->par[i-1];
}
void UndoCommands( int u ) {
    s[++ptr] = s[ptr - u];
}

void GetLetter( int p ) {
    int pos = s[ptr]->sz - p - 1;
    node *now = s[ptr];
    for( int i = 19 ; i >= 0 ; i++ ) if( d >> i & 1 ) now = now -> par[i];
    return now->d;
}

Compilation message

scrivener.cpp:12:2: error: expected ';' after struct definition
 }
  ^
  ;
scrivener.cpp: In function 'void Init()':
scrivener.cpp:19:12: error: 'null' was not declared in this scope
     s[0] = null;
            ^~~~
scrivener.cpp:19:12: note: suggested alternative: 'kill'
     s[0] = null;
            ^~~~
            kill
scrivener.cpp: In function 'void UndoCommands(int)':
scrivener.cpp:30:7: warning: operation on 'ptr' may be undefined [-Wsequence-point]
     s[++ptr] = s[ptr - u];
       ^~~~~
scrivener.cpp: In function 'void GetLetter(int)':
scrivener.cpp:36:42: error: 'd' was not declared in this scope
     for( int i = 19 ; i >= 0 ; i++ ) if( d >> i & 1 ) now = now -> par[i];
                                          ^
scrivener.cpp:37:17: error: return-statement with a value, in function returning 'void' [-fpermissive]
     return now->d;
                 ^
scrivener.cpp:34:9: warning: unused variable 'pos' [-Wunused-variable]
     int pos = s[ptr]->sz - p - 1;
         ^~~