# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
366207 | algorithm16 | Combo (IOI18_combo) | C++14 | 24 ms | 340 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<iostream>
#include<string>
#include<algorithm>
#include "combo.h"
using namespace std;
/*int press(string s) {
cout << s << "\n";
int a;
cin >> a;
return a;
}*/
string guess_sequence(int N) {
if(N==1) {
if(press("A")) return "A";
else if(press("B")) return "B";
else if(press("X")) return "X";
return "Y";
}
string s="";
int x=0;
/*x=press("AABABBBXBY");
if(x==1) s+="A";
else if(x==2) s+="B";
else {
x=press("XXYAYBYXYY");
if(x==1) s+="X";
else if(x==2) s+="Y";
}*/
x=press("A");
if(x) s+="A";
else {
x=press("B");
if(x) s+="B";
else {
x=press("X");
if(x) s+="X";
else s+="Y";
}
}
for(int i=1;i<N-1;i++) {
string s2="";
if(s[0]=='A') s2=s+"B"+s+"XB"+s+"XX"+s+"XY";
if(s[0]=='B') s2=s+"A"+s+"XA"+s+"XX"+s+"XY";
if(s[0]=='X') s2=s+"A"+s+"BA"+s+"BB"+s+"BY";
if(s[0]=='Y') s2=s+"A"+s+"BA"+s+"BB"+s+"BX";
int x=press(s2);
if(x==s.size()+1) {
if(s[0]=='A') s+="B";
else s+="A";
continue;
}
else if(x==s.size()+2) {
if(s[0]=='A' or s[0]=='B') s+="X";
else s+="A";
}
else {
if(s[0]=='Y') s+="X";
else s+="Y";
}
}
if(s[0]=='A') {
if(press(s+"B")==N) return s+"B";
if(press(s+"X")==N) return s+"X";
return s+"Y";
}
if(s[0]=='B') {
if(press(s+"A")==N) return s+"A";
if(press(s+"X")==N) return s+"X";
return s+"Y";
}
if(s[0]=='X') {
if(press(s+"A")==N) return s+"A";
if(press(s+"B")==N) return s+"B";
return s+"Y";
}
if(s[0]=='Y') {
if(press(s+"A")==N) return s+"A";
if(press(s+"B")==N) return s+"B";
return s+"X";
}
}
/*int main()
{
int n;
cin >> n;
cout << guess_sequence(n);
return 0;
}*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |