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;
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 += ("" + 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:38:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
38 | while (cur.size() < N)
| ~~~~~~~~~~~^~~
combo.cpp:41:13: 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 (query == cur.size() + 2)
| ~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:43:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
43 | else if (query == cur.size() + 1)
| ~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:45:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
45 | else if (query == cur.size())
| ~~~~~~^~~~~~~~~~~~~
combo.cpp:48:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
48 | if (query == cur.size() + 1)
| ~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:50:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
50 | else if (query == cur.size())
| ~~~~~~^~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |