Submission #638640

#TimeUsernameProblemLanguageResultExecution timeMemory
638640rockoanaCombo (IOI18_combo)C++17
100 / 100
37 ms588 KiB
#include "combo.h" using namespace std; std::string guess_sequence(int N) { int n = N; string res = ""; string lft = ""; // first letter string q = "AB"; int c = press(q); if (c >= 1) { q = "B"; c = press(q); if (c) { res += 'B'; lft = "AXY"; } else { res += 'A'; lft = "BXY"; } } else { q = "X"; c = press(q); if (c) { res += 'X'; lft = "ABY"; } else { res += 'Y'; lft = "ABX"; } } if (n == 1) { return res; } // next letters while (res.size() < n - 1) { q = res + lft[0]; q += res + lft[1] + lft[1]; q += res + lft[1] + lft[0]; q += res + lft[1] + lft[2]; c = press(q); if (c == res.size()) { res += lft[2]; } else if (c == res.size() + 1) { res += lft[0]; } else { res += lft[1]; } } // last letter q = res + lft[0]; q += res + lft[1]; c = press(q); if (c == n) { q = res + lft[0]; c = press(q); if (c == n) { res += lft[0]; } else { res += lft[1]; } } else { res += lft[2]; } return res; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:40:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   40 |   while (res.size() < n - 1) {
      |          ~~~~~~~~~~~^~~~~~~
combo.cpp:48:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |     if (c == res.size()) {
      |         ~~^~~~~~~~~~~~~
combo.cpp:50:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     } else if (c == res.size() + 1) {
      |                ~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...