Submission #120743

# Submission time Handle Problem Language Result Execution time Memory
120743 2019-06-25T11:31:45 Z MAMBA Crayfish scrivener (IOI12_scrivener) C++17
0 / 100
344 ms 262144 KB
#include <bits/stdc++.h>

using namespace std;

#define rep(i, j, k) for (int i = j; i < int(k); i++)

constexpr int N = 1e6 + 10;

struct node {
  node* par[20];
  char c = '\0';
  int deep = -1;
  node() { fill(par, par + 20, this); }
  node(char c_, node* p) {
    par[0] = p, c = c_;
    deep = p->deep + 1;
    rep(i, 1, 20) par[i] = par[i - 1]->par[i - 1];
  }
} state[N];

int now;
void Init() { now = 1; }

void TypeLetter(char L) { state[now++] = node(L, &state[now - 2]); }

void UndoCommands(int U) { state[now++] = state[now - U - 2]; }

char GetLetter(int P) {
  int goUp = state[now - 1].deep - P;
  node* me = &state[now - 1];
  rep(i, 0, 20) if (goUp >> i & 1) me = me->par[i];
  return me->c;
}

Compilation message

scrivener.cpp: In function 'void TypeLetter(char)':
scrivener.cpp:24:36: warning: operation on 'now' may be undefined [-Wsequence-point]
 void TypeLetter(char L) { state[now++] = node(L, &state[now - 2]); }
                                 ~~~^~
scrivener.cpp: In function 'void UndoCommands(int)':
scrivener.cpp:26:37: warning: operation on 'now' may be undefined [-Wsequence-point]
 void UndoCommands(int U) { state[now++] = state[now - U - 2]; }
                                  ~~~^~
# Verdict Execution time Memory Grader output
1 Runtime error 344 ms 262144 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 342 ms 262144 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 325 ms 262144 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 318 ms 262144 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 313 ms 262144 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -