Submission #785817

#TimeUsernameProblemLanguageResultExecution timeMemory
785817BoasCombo (IOI18_combo)C++17
0 / 100
1 ms256 KiB
#include "combo.h" #include <bits/stdc++.h> #define ALL(x) x.begin(), x.end() using namespace std; string guess_sequence(int N) { vector<char> buttons = {'A', 'B', 'X', 'Y'}; string S; random_device rd; mt19937 g(rd()); while (S.size() < N) { shuffle(buttons.begin(), buttons.end(), g); for (int c = 0; c < buttons.size(); c++) { string p = S + buttons[c]; if (c == buttons.size() - 1) { S = p; if (S.size() == 0) { buttons.erase(find(ALL(buttons), buttons[c])); if (buttons.size() == 4) throw; } break; } else { if (S.size() > 0) { while (p.size() < 4 * N) { shuffle(buttons.begin(), buttons.end(), g); p += buttons[0]; } } int res = press(p); if (res > S.size()) { S = string(p.begin(), p.begin() + res); if (S.size() == 0) { buttons.erase(find(ALL(buttons), buttons[c])); if (buttons.size() == 4) throw; } break; } } } } return S; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:13:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   13 |   while (S.size() < N)
      |          ~~~~~~~~~^~~
combo.cpp:16:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for (int c = 0; c < buttons.size(); c++)
      |                     ~~^~~~~~~~~~~~~~~~
combo.cpp:19:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |       if (c == buttons.size() - 1)
      |           ~~^~~~~~~~~~~~~~~~~~~~~
combo.cpp:34:27: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |           while (p.size() < 4 * N)
      |                  ~~~~~~~~~^~~~~~~
combo.cpp:41:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         if (res > S.size())
      |             ~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...