# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
891314 | presko | Combo (IOI18_combo) | C++14 | 13 ms | 1912 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 "combo.h"
//#include<iostream>
std::string guess_sequence(int N)
{
char poss[4];
std::string s="",p="";
char first,use1,use2,use3;
p="AB";
poss[0]='A';
poss[1]='B';
poss[2]='X';
poss[3]='Y';
int res=press(p);
if(res>=1)
{
p="A";
res=press(p);
if(res==1)s="A";
else s="B";
}
else
{
p="X";
res=press(p);
if(res==1)s="X";
else s="Y";
}
if(N==1)return s;
p="";
first=s[0];
if(first=='A'){use1='B';use2='X';use3='Y';}
else
{
use1='A';
if(first=='B'){use2='X';use3='Y';}
else
{
use2='B';
if(first=='X')use3='Y';
else use3='X';
}
}
//std::cout<<s<<"_s "<<use1<<" "<<use2<<" "<<use3<<"\n";
int prev=res;
for(int i=1;i<N-1;i++)
{
p=s+use1;
std::string curr="";
for(int j=0;j<4;j++)
{
if(poss[j]!=first)curr=curr+s+use2+poss[j];
}
p=p+curr;
//std::cout<<p<<" ";
int ret=press(p);
//std::cout<<ret<<"r\n";
if(ret-i==0)s=s+use3;
else if(ret-i==1)s=s+use1;
else s=s+use2;
//std::cout<<s<<"_s\n";
prev=ret;
}
p=s+use1;
res=press(p);
if(res>N-1)s=s+use1;
else
{
p=s+use2;
res=press(p);
if(res>N-1)s=s+use2;
else s=s+use3;
}
return s;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |