Submission #583663

#TimeUsernameProblemLanguageResultExecution timeMemory
583663Mystic03Combo (IOI18_combo)C++17
5 / 100
1 ms220 KiB
#include "combo.h" #include <vector> #include <algorithm> #include <string> using namespace std; std::string guess_sequence(int N) { string s = ""; char c; vector<char> rem{ 'A', 'B', 'X', 'Y' }; if (press("AB")) { if (press("A")) { s.push_back('A'); } else s.push_back('B'); } else { if (press("X")) { s.push_back('X'); } else s.push_back('Y'); } rem.erase(find(rem.begin(), rem.end(), s[0])); for (int i = 1; i < N - 1; i++) { int len = s.size(); string check = s; check.push_back(rem[0]); check.push_back(rem[0]); check += s; check.push_back(rem[0]); check.push_back(rem[1]); check += s; check.push_back(rem[0]); check.push_back(rem[2]); check += s; check.push_back(rem[2]); int newLen = press(check); if (newLen == len + 2) s.push_back(rem[0]); else if (newLen == len + 1) s.push_back(rem[2]); else s.push_back(rem[1]); } string finalAns = s; finalAns.push_back(rem[0]); if (press(finalAns) > s.length()) { return finalAns; } finalAns.pop_back(); finalAns.push_back(rem[1]); if (press(finalAns) > s.length()) { return finalAns; } finalAns.pop_back(); finalAns.push_back(rem[2]); return finalAns; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:52:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |  if (press(finalAns) > s.length()) {
      |      ~~~~~~~~~~~~~~~~^~~~~~~~~~~~
combo.cpp:57:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |  if (press(finalAns) > s.length()) {
      |      ~~~~~~~~~~~~~~~~^~~~~~~~~~~~
combo.cpp:9:7: warning: unused variable 'c' [-Wunused-variable]
    9 |  char c;
      |       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...