Submission #527771

#TimeUsernameProblemLanguageResultExecution timeMemory
527771andreiomdCombo (IOI18_combo)C++11
0 / 100
1 ms272 KiB
#include "combo.h" using namespace std; std::string litere; char FindFirstLetter () { int val = press("AB"); if (val >= 1) { val = press("A"); if (val == 1) return 'A'; else return 'B'; } val = press("X"); if (val == 1) return 'X'; else return 'Y'; } int PrimaIntrebare (std::string ans, std::string posibil) { std::string p; p = ans + posibil[0] + posibil[2]; p = p + ans + posibil[1] + posibil[2]; p = p + ans + posibil[0] + posibil[0]; return press(p); } int ADouaIntrebare (std::string ans, std::string posibil) { std::string p; p = ans + posibil[0] + posibil[2]; return press(p); } int ATreiaIntrebare (std::string ans, std::string posibil) { std::string p; p = ans + posibil[1] + posibil[0]; return press(p); } std::string guess_sequence(int N) { char ch = FindFirstLetter(); std::string ans; ans.push_back(ch); litere = "ABXY"; std::string unused_litere; for (int i = 0; i < 4; ++ i ) if (ch != litere[i]) unused_litere.push_back(litere[i]); for (int i = 2; i <= N; i += 2) { int val = PrimaIntrebare(ans, unused_litere); if (val == ans.size()) { ans.push_back(unused_litere[2]); i --; } else if (val == ans.size() + 2) { val = ADouaIntrebare(ans, unused_litere); if (val == ans.size()) { ans.push_back(unused_litere[1]); ans.push_back(unused_litere[2]); } else if (val == ans.size() + 1) { ans.push_back(unused_litere[0]); ans.push_back(unused_litere[0]); } else { ans.push_back(unused_litere[0]); ans.push_back(unused_litere[2]); } } else { val = ATreiaIntrebare(ans, unused_litere); if (val == ans.size()) { ans.push_back(unused_litere[0]); ans.push_back(unused_litere[1]); } else if (val == ans.size() + 1) { ans.push_back(unused_litere[1]); ans.push_back(unused_litere[1]); } else { ans.push_back(unused_litere[1]); ans.push_back(unused_litere[0]); } } } return ans; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:59:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |         if (val == ans.size()) {
      |             ~~~~^~~~~~~~~~~~~
combo.cpp:63:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |         else if (val == ans.size() + 2) {
      |                  ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:66:21: 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 (val == ans.size()) {
      |                 ~~~~^~~~~~~~~~~~~
combo.cpp:70:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |             else if (val == ans.size() + 1) {
      |                      ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:82:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   82 |             if (val == ans.size()) {
      |                 ~~~~^~~~~~~~~~~~~
combo.cpp:86:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   86 |             else if (val == ans.size() + 1) {
      |                      ~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...