/*input
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef vector<pi> vpi;
typedef vector<vpi> vpii;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<pd> vpd;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef std::string str;
typedef std::vector<str> vs;
#define x first
#define y second
#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"
const int MOD = 1000000007;
const ll INF = std::numeric_limits<ll>::max();
const int MX = 100101;
const ld PI = 3.14159265358979323846264338327950288419716939937510582097494L;
template<typename T>
pair<T, T> operator+(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x + b.x, a.y + b.y); }
template<typename T>
pair<T, T> operator-(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x - b.x, a.y - b.y); }
template<typename T>
T operator*(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.x + a.y * b.y); }
template<typename T>
T operator^(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.y - a.y * b.x); }
template<typename T>
void print(vector<T> vec, string name = "") {
cout << name;
for (auto u : vec)
cout << u << ' ';
cout << '\n';
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
char last;
vii jump;
vi sz;
vector<char> kas;
const int LG = 20;
void Init() {
}
void TypeLetter(char L) {
if (jump.empty()) {
jump.push_back(vi(LG, 0));
sz.push_back(1);
kas.push_back(L);
return;
}
jump.push_back(vi(LG));
sz.push_back(sz.back() + 1);
kas.push_back(L);
int c = sz.size() - 1;
jump[c][0] = c - 1;
for (int i = 1; i < LG; ++i)
jump[c][i] = jump[jump[c][i - 1]][i - 1];
last = L;
}
void UndoCommands(int U) {
int k = sz.size() - 1 - U;
sz.push_back(sz[k]);
jump.push_back(jump[k]);
kas.push_back(kas[k]);
}
char GetLetter(int P) {
int k = sz.back() - P - 1;
int c = (int)sz.size() - 1;
for (int i = 0; i < LG; ++i)
{
if ((k >> i) & 1)
c = jump[c][i];
}
return kas[c];
// assert(buvo.size());
// return gauk(buvo.back(), P);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
512 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
512 KB |
Output is correct |
2 |
Correct |
6 ms |
640 KB |
Output is correct |
3 |
Correct |
6 ms |
896 KB |
Output is correct |
4 |
Correct |
6 ms |
1024 KB |
Output is correct |
5 |
Correct |
10 ms |
768 KB |
Output is correct |
6 |
Correct |
7 ms |
1024 KB |
Output is correct |
7 |
Correct |
7 ms |
896 KB |
Output is correct |
8 |
Correct |
6 ms |
1024 KB |
Output is correct |
9 |
Correct |
7 ms |
1024 KB |
Output is correct |
10 |
Correct |
6 ms |
1024 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
596 ms |
88172 KB |
Output is correct |
2 |
Correct |
715 ms |
111380 KB |
Output is correct |
3 |
Correct |
561 ms |
111340 KB |
Output is correct |
4 |
Correct |
609 ms |
117972 KB |
Output is correct |
5 |
Correct |
630 ms |
103536 KB |
Output is correct |
6 |
Correct |
589 ms |
120432 KB |
Output is correct |
7 |
Correct |
691 ms |
105328 KB |
Output is correct |
8 |
Correct |
691 ms |
117488 KB |
Output is correct |
9 |
Correct |
731 ms |
112592 KB |
Output is correct |
10 |
Correct |
439 ms |
125552 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
659 ms |
80816 KB |
Output is correct |
2 |
Correct |
697 ms |
82572 KB |
Output is correct |
3 |
Correct |
548 ms |
94256 KB |
Output is correct |
4 |
Correct |
550 ms |
85256 KB |
Output is correct |
5 |
Correct |
556 ms |
107884 KB |
Output is correct |
6 |
Correct |
595 ms |
111624 KB |
Output is correct |
7 |
Correct |
581 ms |
111456 KB |
Output is correct |
8 |
Correct |
810 ms |
95728 KB |
Output is correct |
9 |
Correct |
789 ms |
91884 KB |
Output is correct |
10 |
Correct |
395 ms |
124012 KB |
Output is correct |