Submission #256247

# Submission time Handle Problem Language Result Execution time Memory
256247 2020-08-02T12:02:53 Z StevenH Crayfish scrivener (IOI12_scrivener) C++14
0 / 100
434 ms 262148 KB
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
struct Node
{
  Node *l, *r;
  char c;
} node[maxn * 30], *root[maxn];
Node *nullnode;
int cnt = 0, v = 0;
int len[maxn];
Node *newNode()
{
  Node *res = &node[++cnt];
  res->l = nullnode;
  res->r = nullnode;
  return res;
}
void build(Node *&u, int x, int y)
{
  u = newNode();
  if (x == y)
    return;
  int mid = (x + y) >> 1;
  build(u->l, x, mid);
  build(u->r, mid + 1, y);
  return;
}
void update(Node *&u, int x, int y, int pos, char c)
{
  Node res = *u;
  u = newNode();
  *u = res;
  if (x == y)
  {
    u->c = c;
    return;
  }
  int mid = (x + y) >> 1;
  if (pos <= mid)
    update(u->l, x, mid, pos, c);
  else
    update(u->r, mid + 1, y, pos, c);
  return;
}
Node *query(Node *u, int x, int y, int pos)
{
  if (x == y)
    return u;
  int mid = (x + y) >> 1;
  if (pos <= mid)
    return query(u->l, x, mid, pos);
  else
    return query(u->r, mid + 1, y, pos);
}
void Init()
{
  cnt = 0;
  node->l = node->r = node;
  nullnode = node;
  build(root[0], 1, 1000000);
  len[0] = 0;
  return;
}

void TypeLetter(char L)
{
  v++;
  root[v] = root[v - 1];
  len[v] = len[v - 1] + 1;
  update(root[v], 1, 1000000, len[v], L);
  return;
}

void UndoCommands(int U)
{
  v++;
  root[v] = root[v - U - 1];
  len[v] = len[v - U - 1];
  return;
}

char GetLetter(int P)
{
  Node *ans = query(root[v], 1, 1000000, P);
  return ans->c;
}
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 47352 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 34 ms 47272 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 48000 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 310 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 434 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -