# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
117488 | someone_aa | Crayfish scrivener (IOI12_scrivener) | C++17 | 232 ms | 64376 KiB |
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>
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
using namespace std;
const int N = (1<<20);
const int LOGN = 20;
char q_type[N];
char last[N];
int len[N], q, position;
int point[N][LOGN];
char type, letter;
int _time, cekori;
int moment;
void Init() {
_time = 1;
moment = 1;
}
void TypeLetter(char letter) {
//cin>>letter;
q_type[_time] = type;
len[_time] = len[_time-1] + 1;
last[_time] = letter;
if(q_type[_time-1] == 'T') point[_time][0] = _time-1;
else if(q_type[_time-1] == 'U') point[_time][0] = point[_time-1][0];
for(int i=1;i<20;i++) {
point[_time][i] = point[point[_time][i-1]][i-1];
}
/*cout<<len[_time]<<" "<<last[_time]<<" Pointers: \n";
for(int i=0;i<20;i++) {
cout<<(1<<i)<<" th-parent: "<<point[_time][i]<<"\n";
}*/
_time++;
}
void UndoCommands(int cekori) {
q_type[_time] = type;
len[_time] = len[_time-cekori-1];
last[_time] = last[_time-cekori-1];
if(q_type[_time-cekori-1] == 'T') point[_time][0] = _time-cekori-1;
else if(q_type[_time-cekori-1] == 'U') point[_time][0] = point[_time-cekori-1][0];
for(int i=1;i<20;i++) {
point[_time][i] = point[point[_time][i-1]][i-1];
}
//cout<<len[_time]<<" "<<point[_time]<<" "<<last[_time]<<"\n";
/*cout<<len[_time]<<" "<<last[_time]<<" Pointers: \n";
for(int i=0;i<20;i++) {
cout<<(1<<i)<<" th-parent: "<<point[_time][i]<<"\n";
}*/
_time++;
}
char GetLetter(int position) {
int ttime = _time - 1;
//cout<<"Query: ";
int temp = len[ttime] - position ;
int c = ttime;
if(q_type[c] == 'U') c = point[c][0];
int left_path = temp;
//cout<<temp<<"\n";
int sum = 0;
for(int i=19;i>=0;i--) {
//cout<<c<<" -> "<<left_path<<"\n";
if(point[c][i] != 0 && left_path - (1<<i) >0 ){
c = point[c][i];
left_path -= (1<<i);
}
}
//cout<<c<<"\n";
return last[c];
}
Compilation message (stderr)
# | 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... |