This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |