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_sequence(int n){
string s="";
s="A";
if(press("AB")){
if(press("A"))s="A";
else s="B";
}
else{
if(press("X"))s="X";
else s="Y";
}
int p;
string c="";
if(p!=1)c+="A";
if(p!=2)c+="B";
if(p!=3)c+="X";
if(p!=4)c+="Y";
for(int i=2;i<n;i++){
string t=s+get_string(s,p);
int val=press(s);
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);
}
if(n>1){
if(press(s+c[0])==n)s+=c[0];
else if(press(s+c[1])==n)s+=c[1];
else s+=c[2];
}
return s;
}
Compilation message (stderr)
combo.cpp: In function 'std::string get_string(std::string, int)':
combo.cpp:39:1: warning: control reaches end of non-void function [-Wreturn-type]
39 | }
| ^
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:77:3: warning: 'p' may be used uninitialized in this function [-Wmaybe-uninitialized]
77 | if(p!=1)c+="A";
| ^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |