# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
751730 | allin27x | 크레이피쉬 글쓰는 기계 (IOI12_scrivener) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int n = (int)1e6+2;
int sgt[2*n]={0};
int op = 0;
char ch[n];
string res = "";
int undo[n]={0};
bool undid = 0;
void update(int l, int r){
for (l+=n, r+=n+1; l<r; l>>=1, r>>=1){
if (l&1) sgt[l--] ^= 1;
if (r&1) sgt[--r] ^= 1;
}
}
int get(int a){
int res = 0;
for (a+=n; a>=1; a>>=1) res ^= sgt[a];
return res;
}
void undoOper(){
for (int i=n-1; i>=0; --i){
if (!undo[i] || !get(i)) continue;
update(i-undo[i], i-1);
sgt[i] = 0;
}
for (int i=0; i<n; i++){
if (sgt[i]) res+=ch[i];
}
}
void init(){return;}
void TypeLetter(char L){
ch[op] = L;
sgt[n+op] = 1;
op++;
}
void UndoCommands(int U){
sgt[n+op] = 1;
undo[op] = U;
op++;
}
char GetLetter(int P){
if (!undid) {undid = 1; undoOper();}
return res[P];
}