# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
486435 | ssense | 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.
#include <bits/stdc++.h>
//#include "combo.h"
#define startt ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
using namespace std;
#define vint vector<int>
#define all(v) v.begin(), v.end()
#define MOD 1000000007
#define MOD2 998244353
#define MX 1000000000
#define MXL 1000000000000000000
#define PI (ld)2*acos(0.0)
#define nax 200005
#define pb push_back
#define sc second
#define fr first
//#define int long long
#define endl '\n'
#define ld long double
#define NO cout << "NO" << endl
#define YES cout << "YES" << endl
string guess_sequence(int n)
{
string s;
vector<char> a(4);
a[0] = 'A'; a[1] = 'B'; a[2] = 'X'; a[3] = 'Y';
s.pb(a[0]); s.pb(a[1]);
int exclude = 0;
int k = press(s);
if(k >= 1)
{
s.pop_back();
k = press(s);
if(k == 0)
{
s.pop_back();
s.pb(a[1]);
exclude = 1;
}
}
else
{
s.pop_back();s.pop_back();
s.pb(a[2]);
k = press(s);
exclude = 2;
if(k == 0)
{
s.pop_back();
s.pb(a[3]);
exclude = 3;
}
}
int one = 0, two = 0, three = 0;
if(exclude == one)
{
one++;
}
two = one+1;
if(two == exclude)
{
two++;
}
three = two+1;
if(three == exclude)
{
three++;
}
for(int i = 0; i < n-2; i++)
{
string now = s+a[one]+a[one]+s+a[one]+a[two]+s+a[one]+a[three]+s+a[two];
k = press(now);
if(k == s.size()+2)
{
s.pb(a[one]);
continue;
}
if(k == s.size()+1)
{
s.pb(a[two]);
continue;
}
if(k == s.size())
{
s.pb(a[three]);
continue;
}
}
s.pb(a[0]); s.pb(a[1]);
k = press(s);
if(k >= s.size()-1)
{
s.pop_back();
k = press(s);
if(k == s.size()-1)
{
s.pop_back();
s.pb(a[1]);
}
}
else
{
s.pop_back();s.pop_back();
s.pb(a[2]);
k = press(s);
if(k == s.size()-1)
{
s.pop_back();
s.pb(a[3]);
}
}
return s;
}