Submission #1209260

#TimeUsernameProblemLanguageResultExecution timeMemory
1209260AksLolCodingCombo (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; // string S = "ABXYY"; // int queries = 0; // int press(string p) { // queries++; // int n = S.size(); // for (int i = n; i > 0; i--) { // if (p.find(S.substr(0, i)) != string::npos) { // return i; // } // } // return 0; // } char chars[] = "ABXY"; string guess_sequence(int n) { // find first char int first = 3; for (int i = 0; i < 3; i++) if (press({chars[i]}) == 1) { first = i; break; } swap(chars[first], chars[3]); // find rest string res = {chars[3]}; for (int i = 1; i < n-1; i++) { string p = res + chars[0]; for (int i = 0; i < 3; i++) p += res + chars[1] + chars[i]; int x = press(p); res += chars[(x == i) ? 2 : (x == i + 1) ? 0 : 1]; } for (int i = 0; i < 2; i++) { if (press(res + chars[i]) == n) { res += chars[i]; break; } } if (res.size() < n) res += chars[2]; return res; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:22:37: error: 'press' was not declared in this scope
   22 |     for (int i = 0; i < 3; i++) if (press({chars[i]}) == 1) {
      |                                     ^~~~~
combo.cpp:33:17: error: 'press' was not declared in this scope; did you mean 'res'?
   33 |         int x = press(p);
      |                 ^~~~~
      |                 res
combo.cpp:37:13: error: 'press' was not declared in this scope; did you mean 'res'?
   37 |         if (press(res + chars[i]) == n) {
      |             ^~~~~
      |             res