Submission #483192

#TimeUsernameProblemLanguageResultExecution timeMemory
483192abc864197532Crayfish scrivener (IOI12_scrivener)C++17
100 / 100
481 ms90564 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...