Submission #590212

#TimeUsernameProblemLanguageResultExecution timeMemory
590212eNGyCrayfish scrivener (IOI12_scrivener)C++17
100 / 100
777 ms144744 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));
  Log[last][0] = V[last];
  for(int i=1; i<25; i++){
    Log[last][i] = Log[Log[last][i-1]][i-1];
  }
}

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 e=0; e < 25; e++){
    if((1<<e)&P)
      n = Log[n][e];
  }
  
  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...