Submission #639974

#TimeUsernameProblemLanguageResultExecution timeMemory
639974haxormanCombo (IOI18_combo)C++14
100 / 100
37 ms588 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { string s; vector<string> letters = {"A", "B", "X", "Y"}; string guess = "AB"; int coins = press(guess); if (coins == 2) { s = "AB"; } else if (coins == 1) { guess = "A"; coins = press(guess); if (coins == 1) { s = "A"; } else { s = "B"; } } else { guess = "X"; coins = press(guess); if (coins == 1) { s = "X"; } else { s = "Y"; } } for (int i = 0; i < 4; ++i) { if (letters[i].back() == s[0]) { letters.erase(letters.begin() + i); break; } } while (s.size() < N) { guess.clear(); guess += s + letters[0]; // YB + A // YB + BA / YB + BB / YB + BX // YBAYBBAYBBBYBBX if (s.size() < N - 1) { for (int i = 0; i < 3; ++i) { guess += s + letters[1] + letters[i]; } } else { guess += s + letters[1]; } //cout << s << ' ' << guess << "\n"; coins = press(guess); if (coins == s.size()) { s += letters[2]; } else if (s.size() == N - 1) { guess = s + letters[0]; coins = press(guess); if (coins == s.size()) { s += letters[1]; } else { s += letters[0]; } } else if (coins == s.size() + 1) { s += letters[0]; } else { s += letters[1]; } } return s; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:46:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   46 |  while (s.size() < N) {
      |         ~~~~~~~~~^~~
combo.cpp:53:16: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   53 |   if (s.size() < N - 1) {
      |       ~~~~~~~~~^~~~~~~
combo.cpp:64:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |   if (coins == s.size()) {
      |       ~~~~~~^~~~~~~~~~~
combo.cpp:67:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   67 |   else if (s.size() == N - 1) {
      |            ~~~~~~~~~^~~~~~~~
combo.cpp:71:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |    if (coins == s.size()) {
      |        ~~~~~~^~~~~~~~~~~
combo.cpp:78:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |   else if (coins == s.size() + 1) {
      |            ~~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...