Submission #119826

#TimeUsernameProblemLanguageResultExecution timeMemory
119826dolphingarlicCrayfish scrivener (IOI12_scrivener)C++14
0 / 100
1080 ms253496 KiB

#include <bits/stdc++.h>
using namespace std;

pair<char, char> v[1000001];
string s, t;
int indx = 0;
bool got = false;

void get() {
  int ptr = indx - 1;
  while (ptr != -1) {
    while (ptr != -1 && v[ptr].first == 'U') ptr -= (int)v[ptr].second + 1;
    s += v[ptr--].second;
  }
  for (int i = 0; i < s.size(); i++) t[i] = s[s.size() - 1 - i]; 
}

void Init() {
}

void TypeLetter(char L) {
  v[indx++] = {'T', L};
}

void UndoCommands(int U) {
  v[indx++] = {'U', (char)U};
}

char GetLetter(int P) {
  if (!got) {
    get();
    got = true;
  }
  return t[P];
}

// int main() {
//   int t;
//   cin >> t;
//   for (int i = 0; i < t; i++) {
//     char c, d; int 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);
//     }
//   }
// }

Compilation message (stderr)

scrivener.cpp: In function 'void get()':
scrivener.cpp:16:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < s.size(); i++) t[i] = s[s.size() - 1 - i]; 
                   ~~^~~~~~~~~~
#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...