Submission #933351

#TimeUsernameProblemLanguageResultExecution timeMemory
933351SulACombo (IOI18_combo)C++17
5 / 100
1 ms596 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; string guess_sequence(int n) { string s; vector<char> a; a.push_back('A'); a.push_back('B'); a.push_back('X'); a.push_back('Y'); int x = press("AB"); if (x == 2) s += "AB"; else if (x == 1) { s = (press("A") == 1 ? "A" : "B"); } else { s = (press("X") == 1 ? "X" : "Y"); } if (n == 1) return s; auto first = find(a.begin(), a.end(), s[0]); a.erase(first); for (int i = s.size(); i < n-1; i++) { x = press(s + a[0] + s + a[1] + a[0] + s + a[1] + a[1] + s + a[1] + a[2]); if (x == s.size()) s += a[2]; else if (x == s.size() + 1) s += a[0]; else s += a[1]; } x = press(s + a[0]); if (x > s.size()) return s + a[0]; else if (press(s + a[1]) > s.size()) return s + a[1]; return s + a[2]; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:27:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |         if (x == s.size()) s += a[2];
      |             ~~^~~~~~~~~~~
combo.cpp:28:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         else if (x == s.size() + 1) s += a[0];
      |                  ~~^~~~~~~~~~~~~~~
combo.cpp:33:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     if (x > s.size()) return s + a[0];
      |         ~~^~~~~~~~~~
combo.cpp:34:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     else if (press(s + a[1]) > s.size()) return s + a[1];
      |              ~~~~~~~~~~~~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...