이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("-O3")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define vl vector<ll>
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define f first
#define s second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define p_b pop_back
using namespace std;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll sz = 1e6+5;
vl ord;
ll n = 0;
char val[sz];
ll p[23][sz], lev[sz];
void Init() {
ord.pb(0);
}
void TypeLetter(char L) {
val[++n] = L;
lev[n] = lev[ord.back()] + 1;
p[0][n] = ord.back();
ord.pb(n);
for(ll i = 1; i < 22; i++)
p[i][n] = p[i-1][p[i-1][n]];
}
void UndoCommands(int U) {
ll f = (ll)(ord.size()) - U - 1;
ord.pb(ord[f]);
}
ll jump(ll x, ll k)
{
for(ll i = 21; i >= 0; i--)
{
if((k >> i) & 1)
x = p[i][x];
}
return x;
}
char GetLetter(int P) {
ll k = lev[ord.back()] - P - 1;
ll f = jump(ord.back(), k);
return val[f];
}
# | 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... |