Submission #401707

#TimeUsernameProblemLanguageResultExecution timeMemory
401707dxz05Combo (IOI18_combo)C++14
100 / 100
46 ms576 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string abxy = "ABXY"; string guess_sequence(int n) { string s; if (press("AB")){ if (press("A")) s = "A"; else s = "B"; } else { if (press("X")) s = "X"; else s = "Y"; } if (n == 1) return s; string abxy2 = abxy; abxy.clear(); for (char ch : abxy2){ if (s[0] != ch) abxy += ch; } while (s.size() < n - 1){ string p; for (int i = 0; i < 3; i++){ p += s + abxy[0] + abxy[i]; } p += s + abxy[1]; int x = press(p); char ch; if (x == s.size()) ch = abxy[2]; else if (x == s.size() + 1) ch = abxy[1]; else ch = abxy[0]; s += ch; } if (press(s + abxy[0]) == n){ s += abxy[0]; } else if (press(s + abxy[1]) == n){ s += abxy[1]; } else s += abxy[2]; return s; }

Compilation message (stderr)

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