Submission #434089

#TimeUsernameProblemLanguageResultExecution timeMemory
434089Tiago_MarquesCombo (IOI18_combo)C++17
5 / 100
1 ms260 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; std::string guess_sequence(int N) { string s, p; char option[4] = {'A', 'B', 'X', 'Y'}; int x; p = "AB"; x = press(p); if (x) { p = "A"; x = press(p); if (x) { s = "A"; } else { s = "B"; swap (option[0], option[1]); } } else { p = "X"; x = press(p); if (x) { s = "X"; swap (option[0], option[2]); } else { s = "Y"; swap (option[0], option[3]); } } while (s.size() < N - 1) { p.clear(); p += s; p += option[1]; p += option[1]; p += s; p += option[1]; p += option[2]; p += s; p += option[1]; p += option[3]; p += s; p += option[2]; p += option[0]; x = press (p); if (x == s.size()) { s += option[3]; } if (x == s.size() + 1) { s += option[2]; } if (x == s.size() + 2) { s += option[1]; } } s += option[1]; if (press (s) == N) return s; s .pop_back(); s += option[2]; if (press(s) == N) return s; s.pop_back(); s += option[3]; return s; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:42:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   42 |     while (s.size() < N - 1)
      |            ~~~~~~~~~^~~~~~~
combo.cpp:58:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |         if (x == s.size())
      |             ~~^~~~~~~~~~~
combo.cpp:62:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |         if (x == s.size() + 1)
      |             ~~^~~~~~~~~~~~~~~
combo.cpp:66:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |         if (x == s.size() + 2)
      |             ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...