Submission #785823

#TimeUsernameProblemLanguageResultExecution timeMemory
785823BoasCombo (IOI18_combo)C++17
5 / 100
3025 ms608 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()); uniform_int_distribution<int> dist(0, 2); 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() == 1) { buttons.erase(find(ALL(buttons), buttons[c])); if (buttons.size() != 3) throw; } break; } else { if (S.size() > 0) { while (p.size() < 4 * N) { int rand = 0; rand = dist(rd); p += buttons[rand]; } } int res = press(p); if (res > S.size()) { S = string(p.begin(), p.begin() + res); if (S.size() == 1) { 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:14:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   14 |   while (S.size() < N)
      |          ~~~~~~~~~^~~
combo.cpp:17:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for (int c = 0; c < buttons.size(); c++)
      |                     ~~^~~~~~~~~~~~~~~~
combo.cpp:20:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |       if (c == buttons.size() - 1)
      |           ~~^~~~~~~~~~~~~~~~~~~~~
combo.cpp:35:27: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   35 |           while (p.size() < 4 * N)
      |                  ~~~~~~~~~^~~~~~~
combo.cpp:43:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         if (res > S.size())
      |             ~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...