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 <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include "combo.h"
typedef long long ll;
typedef long double ld;
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>;
#define all(x) x.begin(), x.end()
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
const ll mod = 998244353;
std::string guess_sequence(int N)
{
string x = "ABXY";
vector<string> y(4);
char z;
string ans;
ll b = press("AB");
if (b)
{
if (press("A"))
{
ans.push_back('A');
// y = "BXBXXXY";
y[0] = "B", y[1] = "XB", y[2] = "XX", y[3] = "XY";
z = 'Y';
}
else
{
ans.push_back('B');
;y[0] = "A", y[1] = "XA", y[2] = "XX", y[3] = "XY";
z = 'Y';
}
}
else
{
if (press("X"))
{
ans.push_back('X');
// y = "ABABYBB";
y[0] = "A", y[1] = "BA", y[2] = "BB", y[3] = "BY";
z = 'Y';
}
else
{
ans.push_back('Y');
// y = "ABABXBB";
y[0] = "A", y[1] = "BA", y[2] = "BB", y[3] = "BX";
z = 'X';
}
}
// cout << ans << ' ';
for (int i = 1; i < N - 1; i++)
{
ll m = ans.size();
b = press(ans + y[0] + ans + y[1] + ans + y[2] + ans + y[3]);
// std::cout << b;
if (b == m + 1)
{
ans.push_back(y[0][0]);
}
else if (b == m + 2)
{
ans.push_back(y[1][0]);
}
else
{
ans.push_back(z);
}
}
if(N==1)
{
return ans;
}
if (press(ans + 'A' + ans + 'B') != ans.size())
{
if (press(ans + 'A') != ans.size())
{
ans.push_back('A');
}
else
{
ans.push_back('B');
}
}
else
{
if (press(ans + 'X') != ans.size())
{
ans.push_back('X');
}
else
{
ans.push_back('Y');
}
}
// cout << ans<<' ';
return ans;
}
Compilation message (stderr)
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:76:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
76 | if (press(ans + 'A' + ans + 'B') != ans.size())
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
combo.cpp:78:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
78 | if (press(ans + 'A') != ans.size())
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
combo.cpp:89:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
89 | if (press(ans + 'X') != ans.size())
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |