# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
491336 | cfalas | Combo (IOI18_combo) | C++17 | 1 ms | 200 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>
using namespace std;
#include "combo.h"
char letters[4] = {'A','B','X','Y'};
char first;
char next(int s){
int fi=-1;
for(int i=0;i<4;i++)
if(letters[i]==first) fi = i;
return letters[(fi + s)%4];
}
string guess_sequence(int N) {
string s = "";
int x = press("AB");
if(x>=1){
if(x == 2) s = "AB";
else if(press("A")==1) s = "A";
else s = "B";
}
else{
if(press("X")==1) s = "X";
else s = "Y";
}
first = s[0];
while((int)s.size()<N-1){
string q = s + next(1);
q += s + next(2) + next(1);
q += s + next(2) + next(2);
q += s + next(2) + next(3);
//cout<<q<<endl;
int x =press(q);
if(x==s.size()) s += next(3);
else if(x==s.size()+1) s+= next(1);
else s+=next(2);
}
if(press(s+next(1))==N) s+=next(1);
else if(press(s+next(2))==N) s+=next(2);
else s+=next(3);
return s;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |