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;
string guess_sequence(int n)
{
string ans,v;
if (press("AB"))
{
if (press("A"))
ans="A",v="BXY";
else
ans="B",v="AXY";
}
else
{
if (press("X"))
ans="X",v="ABY";
else
ans="Y",v="ABX";
}
if (n==1)
return ans;
for (int i=2;i<n;i++)
{
string f;
f+=ans+v[0]+v[0]; //ABB , AXBB
f+=ans+v[0]+v[1]; //ABBABX , AXBBAXBX
f+=ans+v[0]+v[2]; //ABBABXABY , AXBBAXBXAXBY
f+=ans+v[1]; //ABBABXABYAX , AXBBAXBXAXBYAXX
int k=press(f);
if (k==ans.size()+2) //mora da zapocnue so ABB,ABX ili ABY / AXBB,AXBX ili AXBY
ans+=v[0];
else if (k==ans.size()+1) //mora da zapocnue so AX / AXX
ans+=v[1];
else //zapocnue samo so A / AX
ans+=v[2];
}
if (press(ans+v[0])==ans.size()+1)
ans+=v[0];
else if (press(ans+v[1])==ans.size()+1)
ans+=v[1];
else
ans+=v[2];
return ans;
}
Compilation message (stderr)
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:32:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | if (k==ans.size()+2) //mora da zapocnue so ABB,ABX ili ABY / AXBB,AXBX ili AXBY
| ~^~~~~~~~~~~~~~
combo.cpp:34:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | else if (k==ans.size()+1) //mora da zapocnue so AX / AXX
| ~^~~~~~~~~~~~~~
combo.cpp:39:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
39 | if (press(ans+v[0])==ans.size()+1)
| ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
combo.cpp:41:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | else if (press(ans+v[1])==ans.size()+1)
| ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |