Submission #605573

#TimeUsernameProblemLanguageResultExecution timeMemory
605573Clan328Combo (IOI18_combo)C++17
100 / 100
35 ms588 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back int press(std::string p); string guess_sequence(int N) { // Guess first letter string s = ""; if (press("AB") > 0) { if (press("A") > 0) s += 'A'; else s += 'B'; } else { if (press("X") > 0) s += 'X'; else s += 'Y'; } vector<string> letters; if (s[0] != 'A') letters.pb("A"); if (s[0] != 'B') letters.pb("B"); if (s[0] != 'X') letters.pb("X"); if (s[0] != 'Y') letters.pb("Y"); letters.pb(""); letters[3] += s[0]; for (int i = 1; i < N-1; i++) { string q = s + letters[0]+letters[1] + s+ letters[0]+letters[2] + s+letters[0]+letters[0] + s +letters[1]; int ans = press(q); if (ans == s.size()) s += letters[2]; else if (ans == s.size()+1) s += letters[1]; else s += letters[0]; } if (s.size() < N) { if (press(s+letters[0]) > s.size()) s += letters[0]; else if (press(s+letters[1]) > s.size()) s+= letters[1]; else s+=letters[2]; } return s; }

Compilation message (stderr)

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