Submission #164708

#TimeUsernameProblemLanguageResultExecution timeMemory
164708IgorICombo (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include <iostream> #include <string> using namespace std; typedef long long ll; string guess_sequence(int n) { string s; int r = press("AB"); if (r) { int q = press("A"); if (q) s += "A"; else s += "B"; } else { int q = press("X"); if (q) s += "X"; else s += "Y"; } for (int i = 1; i < n; i++) { string r; int q; if (s[0] == 'A') r = s + "BB" + s + "BX" + s + "BY" + s + "X"; if (s[0] == 'B') r = s + "AA" + s + "AX" + s + "AY" + s + "X"; if (s[0] == 'X') r = s + "AA" + s + "AB" + s + "AY" + s + "B"; if (s[0] == 'Y') r = s + "AA" + s + "AB" + s + "AX" + s + "B"; q = press(r) - i; if (s[0] == 'A') if (q == 0) s += "Y"; else if (q == 1) s += "X"; else if (q == 2) s += "B"; if (s[0] != 'A') { if (q == 2) s += "A"; if (s[0] == 'B') if (q == 0) s += "Y"; else if (q == 1) s += "X"; if (s[0] != 'B') { if (q == 1) s += "B"; if (s[0] == 'X') if (q == 0) s += "Y"; if (s[0] != 'X') { if (q == 0) s += 'X'; } } } } return s; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:9:13: error: 'press' was not declared in this scope
    9 |     int r = press("AB");
      |             ^~~~~
combo.cpp:29:12: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
   29 |         if (s[0] == 'A') if (q == 0) s += "Y"; else if (q == 1) s += "X"; else if (q == 2) s += "B";
      |            ^
combo.cpp:33:16: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
   33 |             if (s[0] == 'B') if (q == 0) s += "Y"; else if (q == 1) s += "X";
      |                ^