Submission #251711

#TimeUsernameProblemLanguageResultExecution timeMemory
251711tutisCombo (IOI18_combo)C++17
100 / 100
39 ms632 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; std::string guess_sequence(int N) { string ans; if (press("AB") > 0) { if (press("A") > 0) { ans = "A"; } else { ans = "B"; } } else { if (press("X") > 0) { ans = "X"; } else { ans = "Y"; } } string CHARS; for (char i : "ABXY") { if (i != ans.back()) CHARS.push_back(i); } while (ans.size() + 1 < N) { string x; x += ans; x.push_back(CHARS[0]); x += ans; x.push_back(CHARS[1]); x.push_back(CHARS[0]); x += ans; x.push_back(CHARS[1]); x.push_back(CHARS[1]); x += ans; x.push_back(CHARS[1]); x.push_back(CHARS[2]); int c = press(x); if (c == ans.size()) { ans.push_back(CHARS[2]); } else if (c == ans.size() + 1) { ans.push_back(CHARS[0]); } else { ans.push_back(CHARS[1]); } } while (ans.size() < N) { int t = 2; for (int c : {0, 1}) { string x = ans; x.push_back(CHARS[c]); if (press(x) > ans.size()) t = c; } ans.push_back(CHARS[t]); } return ans; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:35:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   35 |  while (ans.size() + 1 < N)
      |         ~~~~~~~~~~~~~~~^~~
combo.cpp:50:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |   if (c == ans.size())
      |       ~~^~~~~~~~~~~~~
combo.cpp:54:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |   else if (c == ans.size() + 1)
      |            ~~^~~~~~~~~~~~~~~~~
combo.cpp:63:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   63 |  while (ans.size() < N)
      |         ~~~~~~~~~~~^~~
combo.cpp:70:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |    if (press(x) > ans.size())
      |        ~~~~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...