# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
648870 | Litusiano | Combo (IOI18_combo) | C++14 | 39 ms | 744 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<iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string>
#include "combo.h"
using namespace std;
string guess_sequence(int N){
string ans;
int x = 1;
if(press("AB") > 0){
if(press("A")){
ans+='A';
x = 0;
}
else ans+='B';
}
else{
if(press("X")){
ans+='X';
x = 2;
}
else{
ans+='Y';
x = 3;
}
}
string all = "ABXY";
string pos;
for(int i = 0; i<all.size(); ++i){
if(i == x) continue;
pos+=all[i];
}
//cout<<pos<<endl;
/*
Faig una sola opcio amb 0
dos opcions amb 1
cap amb 2
*/
for(int i = 2; i<=N-2; ++i){
string s0 = ans; s0+=pos[0];
string s1,s2,s3;
s1 = s2 = s3 = ans;
s1+=pos[1]; s1+=pos[0]; s2+=pos[1]; s2+=pos[1]; s3+=pos[1]; s3+=pos[2];
string tot = s0+s1+s2+s3;
//if(i == 2) cout<<s0<<" "<<s1<<" "<<s2<<" "<<s3<<endl;
//cout<<s0<<"\n1"<<s1<<"\n2"<<s2<<"\n3"<<s3<<"\n"<<endl;
//cout<<4*N<<" "<<tot.size()<<endl;
int c = press(s0+s1+s2+s3);
//if(i == 2) cout<<c<<" "<<i<<endl;
if(c == i) ans+=pos[0];
else if(c == i+1) ans+=pos[1];
else ans+=pos[2];
}
for(int i = max(2,N-1); i<=N; ++i){
string tot = ans; tot+=pos[0];
tot+=ans; tot+=pos[1];
//cout<<tot<<" "<<press(tot)<<endl;
if(press(tot) >= i){
tot = ans; tot+=pos[0];
if(press(tot) >= i) ans+=pos[0];
else ans+=pos[1];
}
else{
ans+=pos[2];
}
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |