# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
554189 | morasha3 | Combo (IOI18_combo) | C++17 | 16 ms | 324 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+='A';
temp+="XB";
temp+='A';
temp+="XY";
temp+='A';
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+='B';
temp+="XA";
temp+='B';
temp+="XY";
temp+='B';
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+='X';
temp+="AB";
temp+='X';
temp+="AY";
temp+='X';
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+='Y';
temp+="XB";
temp+='Y';
temp+="XA";
temp+='Y';
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... |