# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
751980 | minhcool | Crayfish scrivener (IOI12_scrivener) | C++17 | 435 ms | 73744 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>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
const int N = 1e6 + 5;
const int oo = 1e18 + 7, mod = 1e9 + 7;
mt19937 rng(1);
int n;
int cnt;
int lst[N][25], len[N];
char cc[N];
void Init(){
cnt = 0;
for(int i = 0; i <= 20; i++) lst[0][i] = 0;
len[0] = 0;
}
void TypeLetter(char c){
cnt++;
len[cnt] = len[cnt - 1] + 1;
cc[cnt] = c;
lst[cnt][0] = cnt - 1;
for(int i = 1; i <= 20; i++) lst[cnt][i] = lst[lst[cnt][i - 1]][i - 1];
}
void UndoCommands(int x){
cnt++;
len[cnt] = len[cnt - x - 1];
lst[cnt][0] = lst[cnt - x - 1][0];
cc[cnt] = cc[cnt - x - 1];
for(int i = 1; i <= 20; i++) lst[cnt][i] = lst[lst[cnt][i - 1]][i - 1];
}
char GetLetter(int x){
x++;
int temp = cnt - x;
int pos = cnt;
for(int i = 20; i >= 0; i--) if(temp & (1LL << i)) pos = lst[pos][i];
return cc[pos];
}
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... |