Submission #598252

#TimeUsernameProblemLanguageResultExecution timeMemory
598252jairRSCombo (IOI18_combo)C++17
97 / 100
28 ms640 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; int Press(string s) { // cout << s << ": "; int ans = press(s); // cout << ans << endl; return ans; } void remove(vector<char> &subset, char c) { subset.erase(find(subset.begin(), subset.end(), c)); } std::string guess_sequence(int N) { vector<char> available = {'A', 'B', 'X', 'Y'}; string cur = ""; int a1 = Press("AB"); auto case2 = [&cur, &available](string pressed) { // cout << "Case 2: " << pressed << '\n'; cur = pressed; remove(available, pressed[0]); }; auto case1 = [&cur, &available, &case2](string pressed) { // cout << "Case 1: " << pressed << '\n'; bool isFirst = Press({pressed[0]}); if (isFirst) case2({pressed[0]}); else case2({pressed[1]}); }; if (a1 == 2) case2("AB"); else if (a1 == 1) case1("AB"); else { int a2 = Press("XY"); if (a2 == 2) case2("XY"); else if (a2 == 1) case1("XY"); } while (cur.size() < N) { if (cur.size() == N - 1) { string toPress = cur + available[0] + cur + available[1]; if (Press(toPress) == cur.size()) cur += available[2]; else if (Press(cur + available[0]) == N) cur += available[0]; else cur += available[1]; continue; } string toPress = cur + available[0]; for (int i = 0; i < 3; i++) toPress += cur + available[1] + available[i]; int query = Press(toPress); if (query == cur.size()) cur += available[2]; else if (query == cur.size() + 1) cur += available[0]; else cur += available[1]; } return cur; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:54:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   54 |  while (cur.size() < N)
      |         ~~~~~~~~~~~^~~
combo.cpp:56:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   56 |   if (cur.size() == N - 1)
      |       ~~~~~~~~~~~^~~~~~~~
combo.cpp:59:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |    if (Press(toPress) == cur.size())
      |        ~~~~~~~~~~~~~~~^~~~~~~~~~~~~
combo.cpp:73:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |   if (query == cur.size())
      |       ~~~~~~^~~~~~~~~~~~~
combo.cpp:75:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |   else if (query == cur.size() + 1)
      |            ~~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...