# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
767830 | Alihan_8 | Combo (IOI18_combo) | C++17 | 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;
#define all(x) x.begin(), x.end()
#define pb push_back
#define ln '\n'
//#define int long long
#ifndef FILE
#include "grader.cpp"
#endif // FILE
template <class _T>
bool chmin(_T &x, const _T &y){
bool flag = false;
if ( x > y ){
x = y; flag |= true;
}
return flag;
}
template <class _T>
bool chmax(_T &x, const _T &y){
bool flag = false;
if ( x < y ){
x = y; flag |= true;
}
return flag;
}
string guess_sequence(int N){
string s;
if ( press("AB") ){
s += press("A") ? 'A' : 'B';
} else {
s += press("X") ? 'X' : 'Y';
}
if ( N == 1 ){
return s;
}
vector <char> R;
for ( auto i: "ABXY" ){
if ( s[0] != i ){
R.pb(i);
}
}
for ( int i = 2; i < N; i++ ){
auto f = press(s + R[0] + s + R[1] + R[0] + s + R[1] + R[1] + s + R[1] + R[2]);
if ( f == i - 1 ){
s += R[2];
} else if ( f == i ){
s += R[0];
} else{
assert(f == i + 1);
s += R[1];
}
}
if ( press(s + R[0]) == N ){
s += R[0];
} else if ( press(s + R[1]) == N ){
s += R[1];
} else s += R[2];
return s;
}