# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
237469 | A02 | Combo (IOI18_combo) | C++14 | 42 ms | 612 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<iostream>
#include<vector>
using namespace std;
string guess_sequence(int N) {
string p = "AB";
int coins = press(p);
string S = "";
char first = 'A';
if (coins > 0){
coins = press("A");
if (coins > 0){
S = "A";
first = 'A';
} else {
first = 'B';
S = "B";
}
} else {
coins = press("X");
if (coins > 0){
S = "X";
first = 'X';
} else {
first = 'Y';
S = "Y";
}
}
vector<char> not_first;
vector<char> possible;
possible.push_back('A');
possible.push_back('B');
possible.push_back('X');
possible.push_back('Y');
for (int i = 0; i < 4; i++){
if (possible[i] != first){
not_first.push_back(possible[i]);
}
}
while (S.size() < N){
//cout << S << ' ' << N << endl;
int t = S.size();
if (S.size() == N - 1){
coins = press(S + not_first[0] + S + not_first[1]);
if (coins == t){
S += not_first[2];
break;
}
coins = press(S + not_first[0]);
if (coins == t + 1){
S += not_first[0];
break;
}
S += not_first[1];
break;
}
string to_test = S + not_first[0] + not_first[0] + S + not_first[0] + not_first[1] + S + not_first[0] + not_first[2] + S + not_first[1];
coins = press(to_test);
if (coins == t + 2){
S = S + not_first[0];
}
if (coins == t + 1){
S = S + not_first[1];
}
if (coins == t){
S = S + not_first[2];
}
}
//cout << S << endl;
return S;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |