# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
300577 | aymane7 | Combo (IOI18_combo) | C++17 | 36 ms | 612 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"
#pragma GCC optimize("O2")
#define S second
#define F first
#define PB push_back
#define sz(x) (int) x.size()
#define all(x) x.begin(),x.end()
#define L(x) 2*x
#define R(x) 2*x+1
#define M(x,y) (x+y)/2
using namespace std;
typedef long long ll;
/*
int press(string s){
cout<<s <<"?"<<endl;
int ans;
cin>>ans;
return ans;
}
*/
string guess_sequence(int n){
vector<string> pos;
string ans;
string f;
if(press("A")){
ans="A";
pos.PB("B");
pos.PB("X");
pos.PB("Y");
}
else if(press("B")){
ans="B";
pos.PB("A");
pos.PB("X");
pos.PB("Y");
}
else if(press("X")){
ans="X";
pos.PB("A");
pos.PB("B");
pos.PB("Y");
}
else{
ans="Y";
pos.PB("A");
pos.PB("B");
pos.PB("X");
}
for(int i=2;i<=n-1;i++){
int cnt=0;
string query=ans+pos[0]+ans+pos[1]+pos[0] +ans+pos[1]+pos[1] +ans+pos[1]+pos[2];
assert(sz(query)>=0 && sz(query)<=4*n);
int q=press(query);
if(q==sz(ans))
ans+=pos[2];
else if(q==sz(ans)+1)
ans+=pos[0];
else
ans+=pos[1];
}
if(n==1){
return ans;
}
if(press(ans+pos[0])==n){
ans+=pos[0];
}
else if(press(ans+pos[1])==n){
ans+=pos[1];
}
else{
ans+=pos[2];
}
return ans;
}
/*
int main(){
cout<<guess_sequence(1);
}
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |