Submission #1015866

#TimeUsernameProblemLanguageResultExecution timeMemory
1015866ziyad_alharbiCombo (IOI18_combo)C++17
100 / 100
32 ms17124 KiB
#include <bits/stdc++.h> using namespace std; int n; string ans; int press(string p); void f() { if (ans.size() == n)return; else if (ans.empty()) { int v = press("AB"); if (v == 2) { ans = "AB"; } else if (v == 1) { v = press("A"); if (v)ans = "A"; else { ans = "B"; } } else { v = press("X"); if (v)ans = "X"; else { ans = "Y"; } } f(); } else if (ans.size() == n - 1) { string d = ans; if(d.front()=='A') { d.push_back('B'); int v = press(d); if (v == n) { ans.push_back('B'); } else { d.pop_back(); d.push_back('X'); v = press(d); if (v == n) { ans.push_back('X'); } else { ans.push_back('Y'); } } } if (d.front() == 'B') { d.push_back('A'); int v = press(d); if (v == n) { ans.push_back('A'); } else { d.pop_back(); d.push_back('X'); v = press(d); if (v == n) { ans.push_back('X'); } else { ans.push_back('Y'); } } } if (d.front() == 'X') { d.push_back('A'); int v = press(d); if (v == n) { ans.push_back('A'); } else { d.pop_back(); d.push_back('B'); v = press(d); if (v == n) { ans.push_back('B'); } else { ans.push_back('Y'); } } } if (d.front() == 'Y') { d.push_back('B'); int v = press(d); if (v == n) { ans.push_back('B'); } else { d.pop_back(); d.push_back('X'); v = press(d); if (v == n) { ans.push_back('X'); } else { ans.push_back('A'); } } } } else { string d = ans; if (ans.front() == 'A') { d += "BB"; d += ans; d += "BX"; d += ans; d += "BY"; d += ans; d += "X"; int v = press(d); if (v == ans.size() + 2) { ans.push_back('B'); } else if (v == ans.size() + 1) { ans.push_back('X'); } else { ans.push_back('Y'); } } else if (ans.front() == 'B') { d += "AA"; d += ans; d += "AX"; d += ans; d += "AY"; d += ans; d += "X"; int v = press(d); if (v == ans.size() + 2) { ans.push_back('A'); } else if (v == ans.size() + 1) { ans.push_back('X'); } else { ans.push_back('Y'); } } else if (ans.front() == 'X') { d += "AA"; d += ans; d += "AB"; d += ans; d += "AY"; d += ans; d += "B"; int v = press(d); if (v == ans.size() + 2) { ans.push_back('A'); } else if (v == ans.size() + 1) { ans.push_back('B'); } else { ans.push_back('Y'); } } else { d += "AA"; d += ans; d += "AB"; d += ans; d += "AX"; d += ans; d += "B"; int v = press(d); if (v == ans.size() + 2) { ans.push_back('A'); } else if (v == ans.size() + 1) { ans.push_back('B'); } else { ans.push_back('X'); } } f(); } } string guess_sequence(int N) { n = N; f(); return ans; }

Compilation message (stderr)

combo.cpp: In function 'void f()':
combo.cpp:8:17: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
    8 |  if (ans.size() == n)return;
      |      ~~~~~~~~~~~^~~~
combo.cpp:36:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |  else if (ans.size() == n - 1)
      |           ~~~~~~~~~~~^~~~~~~~
combo.cpp:145:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  145 |    if (v == ans.size() + 2)
      |        ~~^~~~~~~~~~~~~~~~~
combo.cpp:149:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  149 |    else if (v == ans.size() + 1)
      |             ~~^~~~~~~~~~~~~~~~~
combo.cpp:168:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  168 |    if (v == ans.size() + 2)
      |        ~~^~~~~~~~~~~~~~~~~
combo.cpp:172:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  172 |    else if (v == ans.size() + 1)
      |             ~~^~~~~~~~~~~~~~~~~
combo.cpp:191:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  191 |    if (v == ans.size() + 2)
      |        ~~^~~~~~~~~~~~~~~~~
combo.cpp:195:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  195 |    else if (v == ans.size() + 1)
      |             ~~^~~~~~~~~~~~~~~~~
combo.cpp:214:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  214 |    if (v == ans.size() + 2)
      |        ~~^~~~~~~~~~~~~~~~~
combo.cpp:218:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  218 |    else if (v == ans.size() + 1)
      |             ~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...