Submission #195089

# Submission time Handle Problem Language Result Execution time Memory
195089 2020-01-16T06:39:53 Z FieryPhoenix Crayfish scrivener (IOI12_scrivener) C++11
0 / 100
269 ms 137584 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <iomanip>
#include <deque>
#include <cassert>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <chrono>
#include <ctime>
#include <random>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <iterator>
#include <climits>
//#include "scrivener.h"
using namespace std;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
#define INF 2001001001
#define MOD 1000000007
 
int root[1000001];
int nex,version;
int child[1000001],length[1000001];
char c[1000001];
int anc[1000001][20];
bool started=false;
 
void calcAnc(int ind){
  anc[ind][0]=child[ind];
  for (int i=1;i<=19;i++){
    if (anc[ind][i-1]==-1)
      anc[ind][i]=-1;
    else
      anc[ind][i]=anc[anc[ind][i-1]][i-1];
  }
}
 
void Init(){
  for (int i=0;i<=1000000;i++)
    child[i]=-1;
  for (int i=0;i<20;i++)
    anc[0][i]=-1;
}
 
void TypeLetter(char ch){
  if (!started){
    root[0]=0;
    c[0]=ch;
    length[0]=1;
    nex++;
    started=true;
    return;
  }
  version++;
  root[version]=nex;
  length[nex]=length[root[version-1]]+1;
  c[nex]=ch;
  anc[nex][0]=root[version-1];
  calcAnc(nex);
  nex++;
}
 
void UndoCommands(int x){
  version++;
  root[version]=nex;
  length[nex]=length[root[version-x-1]];
  c[nex]=c[root[version-x-1]];
  anc[nex][0]=anc[root[version-x-1]][0];
  calcAnc(nex);
  nex++;
}
 
char GetLetter(int ind){
  ind=length[root[version]]-1-ind;
  int cur=root[version];
  for (int i=19;i>=0;i--){
    if (((1<<i)&ind)!=0)
      cur=anc[cur][i];
  }
  return c[cur];
}

# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 4264 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 4216 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 8400 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 269 ms 137584 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 29 ms 15964 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -