# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1043129 | thatsgonzalez | 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 "combo.h"
#include "bits/stdc++.h"
using namespace std;
int press(string p){
int len = p.size();
int coins = 0;
for (int i = 0, j = 0; i < len; ++i) {
if (j < n && S[j] == p[i]) {
++j;
} else if (S[0] == p[i]) {
j = 1;
} else {
j = 0;
}
coins = std::max(coins, j);
}
return coins;
}
std::string guess_sequence(int N) {
std::string p = "";
int k = 0;
n = N;
int res = press("AB");
if(res){
res = press("A");
if(res) p+="A";
else p+="B";
}
else{
res = press("X");
if(res) p+="X";
else p+="Y";
}
k++;
vector<string> aux;
if(p != "A") aux.push_back("A");
if(p != "B") aux.push_back("B");
if(p != "X") aux.push_back("X");
if(p != "Y") aux.push_back("Y");
for(int i = 1; i<N-1; i++){
string query = p+aux[0]+p+(aux[1]+aux[0])+p+(aux[1]+aux[1])+p+(aux[1]+aux[2]);
res = press(query);
if(res-k == 2){
p+=aux[1];
}
else if(res-k == 1){
p+=aux[0];
}
else{
p+=aux[2];
}
k++;
}
res = press(p + aux[0]);
if(res-k) p += aux[0];
else{
res = press(p+aux[1]);
if(res-k) p+=aux[1];
else p+=aux[2];
}
return p;
}