Submission #170240

#TimeUsernameProblemLanguageResultExecution timeMemory
170240sochoCombo (IOI18_combo)C++14
100 / 100
43 ms616 KiB
#include "bits/stdc++.h" #include "combo.h" using namespace std; int press(string s); string guess_sequence(int N) { int xy = press("XY"); char first; string oth; if (xy > 0) { // x or y int x = press("X"); if (x > 0) { first = 'X'; oth = "ABY"; } else { first = 'Y'; oth = "ABX"; } } else { // a or b int a = press("A"); if (a > 0) { first = 'A'; oth = "BXY"; } else { first = 'B'; oth = "AXY"; } } string found; found += first; if (found.size() == N) return found; for (int i=1; i<N-1; i++) { // to find this i try a few things int curr = i; string qry = ""; qry += (found + oth[0]); // if my res is curr+1, then it must be oth[0] next qry += (found + oth[1] + oth[0]); qry += (found + oth[1] + oth[1]); qry += (found + oth[1] + oth[2]); // and curr+2 means oth[1] // so curr means oth[2] // cout << qry << endl; int res = press(qry); if (res == curr) { found += oth[2]; } else if (res > curr + 1) { found += oth[1]; } else { found += oth[0]; } } string oth0 = found + oth[0]; if (press(oth0) == N) { return oth0; } string oth1 = found + oth[1]; if (press(oth1) == N) { return oth1; } found = found + oth[2]; return found; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:37:21: 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 (found.size() == N) return found;
      |        ~~~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...