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;
}
void remove(vector<char> &subset, char c)
{
subset.erase(find(subset.begin(), subset.end(), c));
}
std::string guess_sequence(int N)
{
vector<char> available = {'A', 'B', 'X', 'Y'};
string cur = "";
int query1 = Press("AB"), query2 = Press("BX");
if (query1 == 2)
cur = "A";
else if (query2 == 2)
cur = "B";
else if (query1 == 0)
{
switch (query2)
{
case 0:
cur = "Y";
break;
case 1:
cur = "X";
break;
}
}
else if (query1 == 1)
{
switch (query2)
{
case 0:
cur = "A";
break;
case 1:
cur = "B";
break;
}
}
remove(available, cur[0]);
while (cur.size() < N)
{
if (cur.size() == N - 1)
{
string toPress = cur + available[0] + cur + available[1];
if (Press(toPress) == cur.size())
cur += available[2];
else if (Press(cur + available[0]) == N)
cur += available[0];
else
cur += available[1];
continue;
}
string toPress = cur + available[0];
for (int i = 0; i < 3; i++)
toPress += cur + available[1] + available[i];
int query = Press(toPress);
if (query == cur.size())
cur += available[2];
else if (query == cur.size() + 1)
cur += available[0];
else
cur += available[1];
}
return cur;
}
Compilation message (stderr)
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:53:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
53 | while (cur.size() < N)
| ~~~~~~~~~~~^~~
combo.cpp:55:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
55 | if (cur.size() == N - 1)
| ~~~~~~~~~~~^~~~~~~~
combo.cpp:58:23: 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 (Press(toPress) == cur.size())
| ~~~~~~~~~~~~~~~^~~~~~~~~~~~~
combo.cpp:72:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
72 | if (query == cur.size())
| ~~~~~~^~~~~~~~~~~~~
combo.cpp:74:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
74 | else if (query == cur.size() + 1)
| ~~~~~~^~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |