Submission #1229789

#TimeUsernameProblemLanguageResultExecution timeMemory
1229789AMel0nCrayfish scrivener (IOI12_scrivener)C++20
0 / 100
484 ms240644 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define FOR(i,N) for(ll i = 0; i < N; i++) #define all(x) (x).begin(), (x).end() #define F first #define S second vector<int> cmd = {0}; // cmd[i] -> index of the cur node after the ith (1-indexed) command vector<char> node; // node value vector<vector<int>> par(2e6, vector<int>(20)); // node parent (binary jumping) int n = 0; // nodes created void Init() {} void TypeLetter(char ch) { par[n][0] = cmd[cmd.size()-1]; cmd.push_back(n); node.push_back(ch); for(int j = 1; j < 20; j++) par[n][j] = par[par[n][j-1]][j-1]; n++; } void UndoCommands(int k) { cmd.push_back(cmd[cmd.size()-1-k]); } char GetLetter(int k) { k -= cmd[cmd.size()-1]; int j = 19; int bru = cmd[cmd.size()-1]; while(j > -1) { if (pow(2, j) <= k) { bru = par[bru][j]; k -= pow(2, j); } j--; } return node[bru]; }
#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...