Submission #208255

# Submission time Handle Problem Language Result Execution time Memory
208255 2020-03-10T12:42:17 Z DodgeBallMan Crayfish scrivener (IOI12_scrivener) C++14
0 / 100
6 ms 632 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] = nullptr;
}
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];
}

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

Compilation message

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];
       ^~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 628 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -