Submission #766921

#TimeUsernameProblemLanguageResultExecution timeMemory
766921MinaheierCombo (IOI18_combo)C++14
100 / 100
34 ms544 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; int press(string p); string guess_sequence(int N) { string s = ""; string guess = ""; string opt = ""; if (press("AB") > 0) { 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'); } for (char c : std::string{"ABXY"}) { if (c == s[0]) continue; opt.push_back(c); } for (int i = 1; i < N; i++) { if (i == N - 1) { if (press(s + opt[0]) > s.size()) s.push_back(opt[0]); else if (press(s + opt[1]) > s.size()) s.push_back(opt[1]); else s.push_back(opt[2]); } else { guess = ""; guess += s + opt[0]; for (char c : opt) { guess += s + opt[1] + c; } int p = press(guess); if (p == s.size()) { s += opt[2]; } else if (p == s.size() + 1) { s += opt[0]; } else { s += opt[1]; } } } return s; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:30:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |             if (press(s + opt[0]) > s.size())
      |                 ~~~~~~~~~~~~~~~~~~^~~~~~~~~~
combo.cpp:32:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |             else if (press(s + opt[1]) > s.size())
      |                      ~~~~~~~~~~~~~~~~~~^~~~~~~~~~
combo.cpp:44:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |             if (p == s.size()) {
      |                 ~~^~~~~~~~~~~
combo.cpp:47:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |             else if (p == s.size() + 1) {
      |                      ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...