# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
152326 | nicolaalexandra | Combo (IOI18_combo) | C++14 | 0 ms | 0 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 <cstring>
#include "combo.h"
using namespace std;
//string s(""), p("");
//int n;
/*int press (string p){ /// asta e query-ul
int sol;
cout<<"query "<<p<<endl;
cin>>sol;
return sol;
}*/
string guesss_sequence (int n){
string s("");
string v("");
/// mai intai trb sa aflu primul caracter
string c("ABXY");
int first;
v += "AB";
if (press(v) == 0){ /// stiu clar ca e X sau Y
v.clear(); v = "X";
if (press(v)){ /// stiu sigur ca e X
s += "X";
first = 2;
} else {
s += "Y";
first = 3;
}
} else {
v.clear(); v = "A";
if (press(v)){
s += "A";
first = 0;
} else {
s += "B";
first = 2;
}}
/// acum determin cele 3 caractere pe care le mai am de pus
int ch1,ch2,ch3;
for (int j=0,pas=0;j<4;j++){
if (j == first)
continue;
pas++;
if (pas == 1) ch1 = j;
if (pas == 2) ch2 = j;
if (pas == 3) ch3 = j;
}
for (int i=1;i<n;i++){
v.clear();
v += s, v += c[ch1];
v += s, v += c[ch2], v += c[ch1];
v += s, v += c[ch2], v += c[ch2];
v += s, v += c[ch2], v += c[ch3];
int val = press (v);
if (val == i){
s += c[ch3];
continue;
}
if (val == i+1)
s += c[ch1];
else s += c[ch2];
}
return s;
}