# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
931998 | ntmin | Combo (IOI18_combo) | C++14 | 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.
#ifdef ntmin
#include "combo.h";
#endif // ntmin
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
#define fi first
#define sc second
vector<string> p = {"A", "B", "X", "Y"};
#ifndef ntmin
int press(string s){
cout << s << '\n';
int t; cin >> t;
return t;
}
#endif
string guess_sequence(int N){
string ans = "";
if(press("AB")){
if(press("A"))
ans = "A";
else ans = "B";
} else if(press("X")) ans = "X"; else ans = "Y";
for(string& t : p){
if(t == ans){
swap(t, p[3]);
p.pop_back();
break;
}
}
for(int i = 1; i < N; ++i){
string tmp = ans + p[0] + p[0] + ans + p[0] + p[1] + ans + p[0] + p[2] + ans + p[1];
if((int)tmp.size() > 4 * N){
if(press(ans + p[0]) == i + 1) ans += p[0];
else if(press(ans + p[1]) == i + 1) ans += p[1];
else ans += p[2];
continue;
}
int t = press(tmp);
if(t == i + 2){
ans.append(p[0]);
continue;
}
if(t == i + 1){
ans.append(p[1]);
continue;
}
ans.append(p[2]);
}
return ans;
}
#ifndef ntmin
int main(){
cout << guess_sequence(5);
}
#endif