Submission #194174

#TimeUsernameProblemLanguageResultExecution timeMemory
194174oscarsierra12Crayfish scrivener (IOI12_scrivener)C++14
5 / 100
161 ms7852 KiB
#include <bits/stdc++.h>
using namespace std ;

const int N = 1e6+2 ;

int last, delCommands;
string let ;
string ot ;
int q ;
int acc[N] ;

void Init() {q = 0 ;last = 0;}

void TypeLetter(char L) {
  ot.push_back ( L );
  ++q ;
  acc[q]++ ; acc[q]+=acc[q-1];
}

void UndoCommands(int U) {
  ++q ;
  last = q ;
  delCommands = U+1;
  //cout << last << ' ' << delCommands << '\n' ;
  reverse ( ot.begin(), ot.end() ) ;
  while ( ot.size() ) {
    let.push_back ( ot.back() ) ;
    ot.pop_back() ;
  }
}

char GetLetter(int P) {
 // cout << last << ' ' << delCommands << ' ' << acc[3] << '\n' ;
  if ( P+1 > acc[last-delCommands] ) {
    P -= acc[last-delCommands] ;
    return ot[P] ;
  }
  return let[P];
}
#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...