Submission #497220

#TimeUsernameProblemLanguageResultExecution timeMemory
497220saarang123Combo (IOI18_combo)C++17
100 / 100
30 ms740 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; string guess_sequence(int N) { string s; if(press("AB")) s = press("A") ? "A" : "B"; else s = press("X") ? "X" : "Y"; if(N == 1) return s; vector<char> left; string original = "ABXY"; for(char c : original) if(c != s[0]) left.push_back(c); for(int i = 1; i < N - 1; i++) { string query = (s + left[0]) + (s + left[1] + left[0]) + (s + left[1] + left[1]) + (s + left[1] + left[2]); int res = press(query); if(res == s.size()) s += left[2]; else if(res == s.size() + 1) s += left[0]; else s += left[1]; } if(press(s + left[0] + s + left[1]) == s.size()) s += left[2]; else s += (press(s + left[0]) == s.size() + 1) ? left[0] : left[1]; return s; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:25:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         if(res == s.size())
      |            ~~~~^~~~~~~~~~~
combo.cpp:27:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |         else if(res == s.size() + 1)
      |                 ~~~~^~~~~~~~~~~~~~~
combo.cpp:33:41: 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(press(s + left[0] + s + left[1]) == s.size())
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
combo.cpp:36:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         s += (press(s + left[0]) == s.size() + 1) ? left[0] : left[1];
      |               ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...