Submission #600560

#TimeUsernameProblemLanguageResultExecution timeMemory
600560MazaalaiCombo (IOI18_combo)C++17
97 / 100
39 ms780 KiB
#include "combo.h" #include <bits/stdc++.h> #define pb push_back using namespace std; // max call (N+2) int press(string p) -> returns max Prefix in p; sz(p) <= 4 * sz(n); // N <= 2000 // characters: A, B, X, Y string guess_sequence(int n) { string p = ""; set <char> tmp = {'A', 'B', 'X', 'Y'}; vector <char> c; { // first character; int x = press("AB"); if (x) { if (x == 2) p = "AB"; else if (press("A")) p = "A"; else p = "B"; } else { if (press("X")) p = "X"; else p = "Y"; } tmp.erase(p[0]); for (auto el : tmp) c.pb(el); } while (p.size()+2 <= n) { string A = p+c[0]+c[0]; string B = p+c[0]+c[1]; string C = p+c[0]+c[2]; string D = p+c[1]; int cur = press(A+B+C+D); if (cur == p.size()) { p.pb(c[2]); } else if (cur == p.size()+1) { p.pb(c[1]); } else if (cur == p.size()+2) { p.pb(c[0]); } } if (p.size() < n) { if ( press(p+c[0]) == n) { p.pb(c[0]); } else if (press(p+c[1]) == n) { p.pb(c[1]); } else if (press(p+c[2]) == n) { p.pb(c[2]); } } return p; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:26:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   26 |     while (p.size()+2 <= n) {
      |            ~~~~~~~~~~~^~~~
combo.cpp:32:17: 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 (cur == p.size()) {
      |             ~~~~^~~~~~~~~~~
combo.cpp:34:24: 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 (cur == p.size()+1) {
      |                    ~~~~^~~~~~~~~~~~~
combo.cpp:36:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         } else if (cur == p.size()+2) {
      |                    ~~~~^~~~~~~~~~~~~
combo.cpp:40:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   40 |     if (p.size() < n) {
      |         ~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...