이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std ;
const int N = 1e6+2 ;
int last, delCommands;
string let ;
string ot ;
int q ;
int acc[N] ;
vector <int> estavaina ;
int lst;
void Init() {q = 0 ;last = 0;lst = 0;}
void TypeLetter(char L) {
ot.push_back ( L );
++q ;
estavaina.push_back ( q ) ;
}
void UndoCommands(int U) {
++q ;
last = q ;
delCommands = U+1;
// cout << last << ' ' << delCommands << '\n' ;
reverse ( ot.begin(), ot.end() ) ;
reverse ( estavaina.begin(), estavaina.end() ) ;
while ( ot.size() ) {
let.push_back ( ot.back() ) ;
ot.pop_back() ;
acc[estavaina.back()] ++ ; acc[estavaina.back()] += acc[lst] ;
lst = estavaina.back() ;
estavaina.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... |