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 <vector>
#include <iostream>
using namespace std;
std::string guess_sequence(int N) {
string ans = "";
// trova il primo carattere
if(press(string("AB")) >= 1) {
ans += (press(string("A")) == 1 ? "A" : "B");
} else {
ans += (press(string("X")) == 1 ? "X" : "Y");
}
vector<string> cs;
if('X' != ans[0]) cs.push_back("X");
if('A' != ans[0]) cs.push_back("A");
if('B' != ans[0]) cs.push_back("B");
if('Y' != ans[0]) cs.push_back("Y");
while((int)ans.length() < N) {
if((int)ans.length() == N-1) {
// trova l'ultimo carattere
if(press(ans + cs[0] + ans + cs[1]) == N) {
ans += (press(ans + cs[0]) == N ? cs[0] : cs[1]);
} else {
ans += cs[2];
}
break;
}
string query = ans + cs[0] + ans + cs[1] + cs[0] + ans + cs[1] + cs[1] + ans + cs[1] + cs[2];
int coins = press(query);
if(coins == (int)ans.length()) ans += cs[2];
else if(coins == (int)ans.length() + 1) ans += cs[0];
else if(coins == (int)ans.length() + 2) ans += cs[1];
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |