This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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");
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:46:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
46 | while (cur.size() < N)
| ~~~~~~~~~~~^~~
combo.cpp:49:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
49 | if (query == cur.size() + 2)
| ~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:51:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
51 | else if (query == cur.size() + 1)
| ~~~~~~^~~~~~~~~~~~~~~~~
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())
| ~~~~~~^~~~~~~~~~~~~
combo.cpp:56:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
56 | if (query == cur.size() + 1)
| ~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:58:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
58 | else if (query == cur.size())
| ~~~~~~^~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |