# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
554190 | morasha3 | Combo (IOI18_combo) | C++17 | 24 ms | 612 KiB |
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 "combo.h"
using namespace std;
string guess_sequence(int N) {
string p = "AB";
int c=press(p);
string ans;
if(c==2)
{
ans+='A';
}
else if(c==1)
{
p='A';
c=press(p);
if(c)
ans+='A';
else ans+='B';
}
else
{
p='X';
c=press(p);
if(c)
ans+='X';
else ans+='Y';
}
if(N==1)return ans;
for(int i=1;i<N-1;i++)
{
if(ans[0]=='A')
{
string temp=ans;
temp+='B';
temp+=ans;
temp+="XB";
temp+=ans;
temp+="XY";
temp+=ans;
temp+="XX";
c=press(temp);
if(c==1+ans.size())
{
ans+='B';
}
else if(c==2+ans.size())
{
ans+='X';
}
else ans+='Y';
}
else if(ans[0]=='B')
{
string temp=ans;
temp+='A';
temp+=ans;
temp+="XA";
temp+=ans;
temp+="XY";
temp+=ans;
temp+="XX";
c=press(temp);
if(c==1+ans.size())
{
ans+='A';
}
else if(c==2+ans.size())
{
ans+='X';
}
else ans+='Y';
}
else if(ans[0]=='X')
{
string temp=ans;
temp+='B';
temp+=ans;
temp+="AB";
temp+=ans;
temp+="AY";
temp+=ans;
temp+="AA";
c=press(temp);
if(c==1+ans.size())
{
ans+='B';
}
else if(c==2+ans.size())
{
ans+='A';
}
else ans+='Y';
}
else
{
string temp=ans;
temp+='B';
temp+=ans;
temp+="XB";
temp+=ans;
temp+="XA";
temp+=ans;
temp+="XX";
c=press(temp);
if(c==1+ans.size())
{
ans+='B';
}
else if(c==2+ans.size())
{
ans+='X';
}
else ans+='A';
}
}
string temp=ans;
if(ans[0]=='A')
{
temp+='B';
c=press(temp);
if(c==N)
ans+='B';
else
{
temp[temp.size()-1]='X';
c=press(temp);
if(c==N)
ans+='X';
else ans+='Y';
}
}
else if(ans[0]=='B')
{
temp+='A';
c=press(temp);
if(c==N)
ans+='A';
else
{
temp[temp.size()-1]='X';
c=press(temp);
if(c==N)
ans+='X';
else ans+='Y';
}
}
else if(ans[0]=='X')
{
temp+='B';
c=press(temp);
if(c==N)
ans+='B';
else
{
temp[temp.size()-1]='A';
c=press(temp);
if(c==N)
ans+='A';
else ans+='Y';
}
}
else
{
temp+='B';
c=press(temp);
if(c==N)
ans+='B';
else
{
temp[temp.size()-1]='X';
c=press(temp);
if(c==N)
ans+='X';
else ans+='A';
}
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |