Submission #164716

#TimeUsernameProblemLanguageResultExecution timeMemory
164716IgorICombo (IOI18_combo)C++17
100 / 100
47 ms588 KiB
#include <combo.h> #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++) { if (i + 1 == n) { string r; int q; if (s[0] == 'X' || s[0] == 'Y') { r = s + "A" + s + "B"; q = press(r) - i; if (q == 0 && s[0] == 'X') return (s + "Y"); if (q == 0 && s[0] == 'Y') return (s + "X"); if (q == 1) { r = s + "A"; q = press(r) - i; if (q == 0) return (s + "B"); if (q == 1) return (s + "A"); } } if (s[0] == 'A' || s[0] == 'B') { r = s + "X" + s + "Y"; q = press(r) - i; if (q == 0 && s[0] == 'A') return (s + "B"); if (q == 0 && s[0] == 'B') return (s + "A"); if (q == 1) { r = s + "X"; q = press(r) - i; if (q == 0) return (s + "Y"); if (q == 1) return (s + "X"); } } break; } 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:64:12: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
   64 |         if (s[0] == 'A') if (q == 0) s += "Y"; else if (q == 1) s += "X"; else if (q == 2) s += "B";
      |            ^
combo.cpp:68:16: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
   68 |             if (s[0] == 'B') if (q == 0) s += "Y"; else if (q == 1) s += "X";
      |                ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...