이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define X first
#define Y second
#define pii pair<int, int>
void abc() {cout << endl;}
template <typename T, typename ...U> void abc(T i, U ...j) {
cout << i << ' ', abc(j...);
}
template <typename T> void printv(T l, T r) {
for (; l != r; ++l) cout << *l << " \n"[l + 1 == r];
}
#ifdef Doludu
#define test(args...) abc("[" + string(#args) + "]", args);
#include "grader_C.cpp"
#else
#define test(args...) void(0);
#endif
const int N = 1000005;
int dsu[N], now = 1;
int jump[N][20], len[N];
char c[N];
void Init() {
for (int i = 0; i < N; ++i)
dsu[i] = i;
}
int Find(int x) {
if (dsu[x] == x)
return x;
return dsu[x] = Find(dsu[x]);
}
void TypeLetter(char L) {
jump[now][0] = Find(now - 1);
for (int j = 1; j < 20; ++j)
jump[now][j] = jump[jump[now][j - 1]][j - 1];
len[now] = len[Find(now - 1)] + 1;
c[now++] = L;
}
void UndoCommands(int U) {
dsu[now] = Find(now - U - 1);
len[now] = len[Find(now - U - 1)];
now++;
}
char GetLetter(int P) {
int d = len[now - 1] - P - 1, cur = Find(now - 1);
for (int i = 0; i < 20; ++i) if (d >> i & 1) {
cur = jump[cur][i];
}
return c[cur];
}
/*
14
T a
T b
P 1
T d
U 2
U 1
P 2
T e
U 1
U 5
T c
P 2
U 2
P 2
*/
# | 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... |