# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1230719 | riddles | 콤보 (IOI18_combo) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;
typedef long long ll;
typedef map<ll, ll> mp;
typedef pair<ll, ll> pll;
typedef queue<ll> qi;
typedef vector<ll> vi;
typedef vector<bool> vb;
typedef vector <vi> vvi;
typedef vector <pll> vpl;
typedef vector <string> vs;
#define YES cout<<"YES\n"
#define Yes cout<<"Yes\n"
#define NO cout<<"NO\n"
#define No cout<<"No\n"
#define F first
#define S second
#define pb push_back
#define all(x) begin(x), end(x)
void setIO(string name = "") {
ios_base::sync_with_stdio(0); cin.tie(0);
if ((ll)(name.size())) {
freopen((name + ".in").c_str(), "r", stdin);
freopen((name + ".out").c_str(), "w", stdout);
}
}
ll go(){
ll q=press("AB");
if(q>=1){
q=press("A");
if(q==1) return 0;
else return 1;
}else{
q=press("X");
if(q==1) return 2;
else return 3;
}
}
string guess_sequence(ll n){
string ans="";
vector<char> idx={'A', 'B', 'X', 'Y'};
ll a=go();
ll q=n-2;
ans+=idx[a];
ll i=1;
if(idx[a]=='A'){
while(q--){
string test="";
test+=ans;
test+='B';
test+=ans;
test+="XY";
test+=ans;
test+="XB";
test+=ans;
test+="XX";
ll k=press(test);
if(k==i) ans+='Y';
else if(k==i+1) ans+='B';
else ans+='X';
i++;
}
}
if(idx[a]=='B'){
while(q--){
string test="";
test+=ans;
test+='A';
test+=ans;
test+="XY";
test+=ans;
test+="XA";
test+=ans;
test+="XX";
ll k=press(test);
if(k==i) ans+='Y';
else if(k==i+1) ans+='A';
else ans+='X';
i++;
}
}
if(idx[a]=='X'){
while(q--){
string test="";
test+=ans;
test+='B';
test+=ans;
test+="AY";
test+=ans;
test+="AB";
test+=ans;
test+="AA";
ll k=press(test);
if(k==i) ans+='Y';
else if(k==i+1) ans+='B';
else ans+='A';
i++;
}
}
if(idx[a]=='Y'){
while(q--){
string test="";
test+=ans;
test+="B";
test+=ans;
test+="XA";
test+=ans;
test+="XB";
test+=ans;
test+="XX";
ll k=press(test);
if(k==i) ans+='A';
else if(k==i+1) ans+='B';
else ans+='X';
i++;
}
}
return ans;
}