# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
119910 | 2019-06-22T15:23:27 Z | dolphingarlic | Crayfish scrivener (IOI12_scrivener) | C++14 | 0 ms | 0 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; pair<char, ll> v[1000005]; char s[1000005]; ll indx = 0, i = 0; bool got = false; void Init() { } void TypeLetter(char L) { v[indx++] = {'T', L - 'a'}; } void UndoCommands(ll U) { v[indx++] = {'U', U + 1}; } char GetLetter(ll P) { if (!got) { ll ptr = indx - 1; while (ptr > -1) { while (v[ptr].first == 'U') ptr -= v[ptr].second; s[i++] = (char)(v[ptr--].second + 'a'); } got = true; } return s[i - 1 - P]; } // int main() { // ll t; // cin >> t; // Init(); // for (ll i = 0; i < t; i++) { // char c, d; ll e; // cin >> c; // switch (c) { // case 'T': // cin >> d; // TypeLetter(d); // break; // case 'P': // cin >> e; // cout << GetLetter(e) << '\n'; // break; // default: // cin >> e; // UndoCommands(e); // } // } // }