# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
476850 | Valaki2 | Combo (IOI18_combo) | C++14 | 42 ms | 580 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 n;
string ans;
vector<char> letters = {'A', 'B', 'X', 'Y'};
void getFirst() {
char firstChar;
int x = press("AB");
int y = press("AX");
if(x == 0) {
if(y == 0) {
firstChar = 'Y';
} else {
firstChar = 'X';
}
} else {
if(y == 0) {
firstChar = 'B';
} else {
firstChar = 'A';
}
}
ans.push_back(firstChar);
auto toErase = letters.begin();
for(auto it = letters.begin(); it != letters.end(); it++) {
if(*it == firstChar) {
toErase = it;
}
}
letters.erase(toErase);
}
void getLast() {
for(int i = 0; i < 2; i++) {
if(press(ans + letters[i]) == n) {
ans.push_back(letters[i]);
break;
}
}
if(ans.size() != n) {
ans.push_back(letters.back());
}
}
string guess_sequence(int N) {
n = N;
getFirst();
if(n == 1) {
return ans;
}
for(int i = 2; i < n; ++i) {
int x = press(ans + letters[0] + ans + letters[1] + letters[0] + ans + letters[1] + letters[1] + ans + letters[1] + letters[2]);
if(x == i - 1) {
ans.push_back(letters[2]);
}
if(x == i) {
ans.push_back(letters[0]);
}
if(x == i + 1) {
ans.push_back(letters[1]);
}
}
getLast();
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |