Submission #1016357

#TimeUsernameProblemLanguageResultExecution timeMemory
1016357FaggiCrayfish scrivener (IOI12_scrivener)C++11
5 / 100
5 ms3164 KiB
#include <bits/stdc++.h> using namespace std; // Stores the current text and history of commands vector<char> text; stack<pair<int, vector<char>>> history; void Init() { // Initialize empty text and history text.clear(); history.push({0, vector<char>()}); } void TypeLetter(char L) { // Append letter to text and update history text.push_back(L); history.push({history.top().first + 1, vector<char>()}); } void UndoCommands(int U) { // Undo U commands in reverse order for (int i = 0; i < U; i++) { int prevSize = history.top().first; vector<char> undo = history.top().second; // If TypeLetter was undone, remove the letter and previous commands if (undo.empty()) { text.resize(prevSize); } else { // Redo previously undone commands (UndoCommands) for (char c : undo) { text.push_back(c); } } history.pop(); } } char GetLetter(int P) { // Return letter at position P based on current state return text[P]; }
#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...