# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
205674 | SoGood | Combo (IOI18_combo) | C++17 | 59 ms | 588 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;
string guess_sequence(int N) {
vector<char> v = {'A', 'B', 'X', 'Y'};
string ans="";
if (press("AB")) {
if (press("A")) ans += 'A';
else ans += 'B';
} else {
if (press("X")) ans += 'X';
else ans += 'Y';
}
if (N==1) return ans;
vector<char> vec;
for (char d : v) if (d != ans[0]) vec.push_back(d);
for (int i = 1; i < N - 1; ++i) {
string ask = ans + vec[0] + ans + vec[1] + vec[0] + ans + vec[1] + vec[1] + ans + vec[1] + vec[2];
int res=press(ask);
if (res==ans.size()) ans += vec[2];
else if (res == ans.size() + 1) ans += vec[0];
else ans += vec[1];
}
for (char d : vec) {
if (d==vec.back()) break;
ans+=d;
if (press(ans)==N) return ans;
ans.pop_back();
}
ans+=vec.back();
return ans;
}
/**
abcccbd
abacad
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |