Submission #590072

#TimeUsernameProblemLanguageResultExecution timeMemory
590072eNGyCrayfish scrivener (IOI12_scrivener)C++17
0 / 100
269 ms105312 KiB
#include <bits/stdc++.h>
#define pb push_back

using namespace std;

vector<int> V, D;
vector<char> C;

vector<vector<int>> Log;
int last = 0;

void Init(){
  V.pb(-1);
  D.pb(-1);
  C.pb('$');

  Log.pb(vector<int>(25, 0));
}

void prepross(){
  Log.pb(vector<int>(25, 0));

  int i=0; 
  while(Log[last][i] != 0){
    Log[last][i+1] = Log[Log[last][i]][i];
    i++;
  }
}

void TypeLetter(char L){
  C.pb(L),
  V.pb(last);
  D.pb(D[last]+1);
  last++;

  prepross();
}

void UndoCommands(int U){
  C.pb(C[last-U]);
  V.pb(V[last-U]);
  D.pb(D[last-U]);
  Log.pb(Log[last-U]);
  last++;
}

char GetLetter(int P){
  int n = last;
  P = D[n] - P;
  for(int p=1, e=0; P>0; p *= 2, e++){
    n = Log[n][e];
    P -= p;
  }

  return C[n];
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...