| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1315808 | phamducluong | Combo (IOI18_combo) | C++17 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
//#include "combo.h"
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
using ll=long long;
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define mem(a,x) memset(a,x,sizeof(a))
#define fast(s) s.reserve(2000); s.max_load_factor(0.5);
#define F first
#define S second
#define pii pair <int,int>
#define iii tuple<int,int,int>
#define all(p) p.begin(), p.end()
template<typename T> bool maximum(T &A, const T &B) {return A<B? A=B, true: false;}
template<typename T> bool minimum(T &A, const T &B) {return A>B? A=B, true: false;}
template<typename T> T gcd(T t) {return t;}
template<typename T, typename... Args> T gcd(T t, Args... args) {return __gcd(t,args...);};
void print(bool condition=1) {cout<<(condition? "YES\n": "NO\n");}
const int mod=1e9+7;
const int INF=1e9;
const int N=5e5+5, LOG=20;
const string s="ABXY";
//const string base="ABXYY";
//int press(string p)
//{
// cout<<"ask "<<p<<"\n";
// int cnt; cin>>cnt;
// return cnt;
//}
string guess_sequence(int n)
{
string res, cand, t;
int cnt=press("AB");
if(cnt)
{
cnt=press("A");
if(cnt) res+='A';
else res+='B';
}
else
{
cnt=press("X");
if(cnt) res+='X';
else res+='Y';
}
for(int i=0; i<4; ++i)
if(s[i]!=res.front()) cand+=s[i];
for(int i=1; i<n-1; ++i)
{
t=(res+cand[0]+cand[0]+res+cand[0]+cand[1]+res+cand[0]+cand[2]+res+cand[1]);
cnt=press(t);
if(cnt==(int)res.size()) res+=cand[2];
else if(cnt==(int)res.size()+1) res+=cand[1];
else res+=cand[0];
}
t=s+cand[0];
cnt=press(t);
if(cnt>(int)res.size()) res+=cand[0];
else
{
t=s+cand[1];
cnt=press(t);
if(cnt>(int)res.size()) res+=cand[1];
else res+=cand[2];
}
return res;
}
//signed main()
//{
// cout<<guess_sequence(5);
// return 0;
//}
