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)
{
int ops = 0;
vector<string> cc{"A", "B", "X", "Y"};
string ans;
for(int i=0;i<3;i++)
if(press(cc[i]))
ans += cc[i], ops++;
if(ans.empty())
ans += cc[3];
vector<string> controls;
for(int i=0;i<4;i++)
{
if(cc[i] != ans)
controls.push_back(cc[i]);
}
string cur;
if(n == 1)
return ans;
for(int i=1;i<n-1;i++)
{
// cout << ans << '\n';
cur = ans + controls[1] + ans + controls[0] + controls[0] + ans + controls[0] + controls[1] + ans + controls[0] + controls[2];
// cout << cur.size() << '\n';
ops++;
int len = press(cur);
if(len == i + 2)
ans += controls[0];
else if(len == i + 1)
ans += controls[1];
else
ans += controls[2];
}
// Since len(cur) > 4N
if(press(ans + controls[0]) == n)
ans += controls[0];
else if(press(ans + controls[1]) == n)
ans += controls[1];
else
ans += controls[2];
// cout << ops << '\n';
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |