Submission #598227

#TimeUsernameProblemLanguageResultExecution timeMemory
598227jairRSCombo (IOI18_combo)C++17
0 / 100
1 ms208 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; } 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) { // cout << "Case 2: " << pressed << '\n'; cur = pressed; available.erase(find(available.begin(), available.end(), 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 (a2 == 2) case2("XY"); else if (a1 == 1) case1("AB"); else if (a2 == 1) case1("XY"); cout << "first letter found: " << cur << '\n'; while (cur.size() < N) { int query = Press(cur + available[0] + available[1]); if (query == cur.size() + 2) cur += (string() + 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:48:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   48 |  while (cur.size() < N)
      |         ~~~~~~~~~~~^~~
combo.cpp:51:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |   if (query == cur.size() + 2)
      |       ~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:53:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |   else if (query == cur.size() + 1)
      |            ~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:55:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |   else if (query == cur.size())
      |            ~~~~~~^~~~~~~~~~~~~
combo.cpp:58:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |    if (query == cur.size() + 1)
      |        ~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:60:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |    else if (query == cur.size())
      |             ~~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...