# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
162305 | Nordway | 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"combo.h"
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define nl '\n'
#define boost ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const ll INF=1e18;
const int inf=1e9;
const ld eps=1e-7;
const ld pi=acos(-1);
const int dx[8]={0,0 ,1,-1,1,1,-1,-1};
const int dy[8]={1,-1,0,0,1,-1,1,-1};
const int mod1=998244353;
const int mod=1e9+7;
const int N=5e5+11;
const int M=511111;
string get_string(string s,int p){
if(p==1)return "B"+s+"XB"+s+"XX"+s+"XY";
else if(p==2)return "X"+s+"YX"+s+"YY"+s+"YA";
else if(p==3)return "Y"+s+"AY"+s+"AA"+s+"AB";
else if(p==4)return "A"+s+"BA"+s+"BB"+s+"BX";
}
string get_char(int val,int p){
if(p==4){
if(val==0)return "X";
else if(val==1)return "A";
else return "B";
}
else if(p==1){
if(val==0)return "Y";
else if(val==1)return "B";
else return "X";
}
else if(p==2){
if(val==0)return "A";
else if(val==1)return "X";
else return "Y";
}
else {
if(val==0)return "B";
else if(val==1)return "Y";
else return "A";
}
}
string guess_string(int n){
string s="";
s="A";
int p;
if(press(s)==1){
p=1;
}
else{
s="B";
if(press(s)==1){
p=2;
}
else{
s="X";
if(press(s)){
p=3;
}
else{
s="Y";
p=4;
}
}
}
for(int i=2;i<=n;i++){
string t=s+get_string(s,p);
int val=press(t);
if(val==sz(s))s=s+get_char(0,p);
else if(val==sz(s)+1)s=s+get_char(1,p);
else if(val==sz(s)+2)s=s+get_char(2,p);
}
return s;
}