Submission #926927

#TimeUsernameProblemLanguageResultExecution timeMemory
926927bobbilykingCombo (IOI18_combo)C++17
94 / 100
17 ms1756 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; std::string guess_sequence(int N) { vector<char> poss{'A', 'B', 'X', 'Y'}; string cur; for (char c: poss) { string s; s += c; if (press(s)) { poss.erase(find(poss.begin(), poss.end(), c)); cur = s; break; } } auto dumbextend = [&]() { bool done = 0; for (int i = 0; i < 2; ++i) { cur += poss[i]; if (press(cur) == cur.size()) { done = 1; break; } cur.pop_back(); } if (!done) cur += poss[2]; }; while (cur.size() < N) { // might not need this, but im scared of querying too mayn letters // dumbextend(); continue; if (cur.size() + 1 == N) dumbextend(); else { string temp; temp += cur + poss[0]; for (int j= 0 ; j < 3; ++j) temp += (cur + poss[1]) + poss[j]; auto res = press(temp); if (res == cur.size()) cur += poss[2]; else if (res == cur.size() + 1) cur += poss[0]; else cur += poss[1]; } } // cout << "WTF " << cur << endl; // cout << cur << " " << cur.size() << " " << N << endl; assert(cur.size() == N); return cur; }

Compilation message (stderr)

combo.cpp: In lambda function:
combo.cpp:21:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |             if (press(cur) == cur.size()) {
      |                 ~~~~~~~~~~~^~~~~~~~~~~~~
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:29:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   29 |     while (cur.size() < N) {
      |            ~~~~~~~~~~~^~~
combo.cpp:32:28: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   32 |         if (cur.size() + 1 == N) dumbextend();
      |             ~~~~~~~~~~~~~~~^~~~
combo.cpp:39:21: 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 (res == cur.size()) cur += poss[2];
      |                 ~~~~^~~~~~~~~~~~~
combo.cpp:40:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |             else if (res == cur.size() + 1) cur += poss[0];
      |                      ~~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from combo.cpp:2:
combo.cpp:47:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   47 |     assert(cur.size() == N);
      |            ~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...