Submission #594041

#TimeUsernameProblemLanguageResultExecution timeMemory
594041jairRSCombo (IOI18_combo)C++17
0 / 100
1 ms464 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; std::string guess_sequence(int N) { vector<char> available = {'A', 'B', 'X', 'Y'}; string cur = ""; int a1 = press("AB"); int a2 = press("XY"); auto case2 = [&cur, &available](string pressed) { cur = pressed; available.erase(find(available.begin(), available.end(), pressed[0])); }; auto case1 = [&cur, &available, &case2](string pressed) { bool isFirst = press("" + pressed[0]); if (isFirst) case2("" + pressed[0]); else case2("" + pressed[1]); }; if (a1 == 2) case2("AB"); else if (a2 == 2) case2("XY"); else if (a1 == 1) case1("AB"); else if (a2 == 1) case1("XY"); while (cur.size() < N) { int query = press(cur + available[0] + available[1]); if (query == cur.size() + 2) cur += ("" + available[0] + available[1]); else if (query == cur.size() + 1) cur += available[0]; else if (query == cur.size()) { query = press(cur + available[1]); if (query == cur.size() + 1) cur += available[1]; else if (query == cur.size()) cur += available[2]; } } return cur; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:36:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |  while (cur.size() < N)
      |         ~~~~~~~~~~~^~~
combo.cpp:39:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |   if (query == cur.size() + 2)
      |       ~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:41:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |   else if (query == cur.size() + 1)
      |            ~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:43:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |   else if (query == cur.size())
      |            ~~~~~~^~~~~~~~~~~~~
combo.cpp:46:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |    if (query == cur.size() + 1)
      |        ~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:48:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |    else if (query == cur.size())
      |             ~~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...