# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
534548 | YaserFaisal | Combo (IOI18_combo) | C++17 | 38 ms | 608 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 call( string cur , int siz )
{
int x ;
if ( cur[0] == 'A' )
{
x = press(cur+'B'+cur+"XX"+cur+"XY"+cur+"XB") ;
if ( x == siz+1 ) return cur+'B' ;
else if ( x == siz+2 ) return cur+'X' ;
else return cur+'Y' ;
}
if ( cur[0] == 'B' )
{
x = press(cur+'A'+cur+"XX"+cur+"XY"+cur+"XA") ;
if ( x == siz+1 ) return cur+'A' ;
else if ( x == siz+2 ) return cur+'X' ;
else return cur+'Y' ;
}
if ( cur[0] == 'X' )
{
x = press(cur+'B'+cur+"AA"+cur+"AY"+cur+"AB") ;
if ( x == siz+1 ) return cur+'B' ;
else if ( x == siz+2 ) return cur+'A' ;
else return cur+'Y' ;
}
if ( cur[0] == 'Y' )
{
x = press(cur+'B'+cur+"XX"+cur+"XA"+cur+"XB") ;
if ( x == siz+1 ) return cur+'B' ;
else if ( x == siz+2 ) return cur+'X' ;
else return cur+'A' ;
}
}
string call2( string cur )
{
int siz = cur.size()+1 ;
if ( cur[0] == 'A' )
{
if ( press(cur+'B') == siz ) return cur+'B' ;
else if ( press(cur+'X') == siz ) return cur+'X' ;
else return cur+'Y' ;
}
if ( cur[0] == 'B' )
{
if ( press(cur+'A') == siz ) return cur+'A' ;
else if ( press(cur+'X') == siz ) return cur+'X' ;
else return cur+'Y' ;
}
if ( cur[0] == 'X' )
{
if ( press(cur+'B') == siz ) return cur+'B' ;
else if ( press(cur+'A') == siz ) return cur+'A' ;
else return cur+'Y' ;
}
if ( cur[0] == 'Y' )
{
if ( press(cur+'B') == siz ) return cur+'B' ;
else if ( press(cur+'X') == siz ) return cur+'X' ;
else return cur+'A' ;
}
}
string guess_sequence (int n)
{
string cur = "" ;
int x = press("AB") ;
if ( x == 0 )
{
if ( press(cur+'X') == 1 ) cur+='X' ;
else cur+='Y' ;
}
else
{
if ( press(cur+'A') == 1 ) cur+='A' ;
else cur+='B' ;
}
while(cur.size()<(n-1)) cur = call(cur,cur.size()) ;
while(cur.size()<n) cur = call2(cur) ;
return cur ;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |