# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
283632 | charterla | Combo (IOI18_combo) | C++14 | 1 ms | 200 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 <iostream>
#include <cstdio>
using namespace std;
int first;
string ans="";
char rule[4]={'A','B','X','Y'};
int p[3];
inline void findFirst(){
string temp;
for(int i=2;i>0;i--){
temp="";
for(int j=first;j<first+i;j++)temp+=rule[j];
//cout<<temp<<endl;
if(press(temp)==0)first+=i;
}
int j=0;for(int i=0;i<4;i++)if(i!=first)p[j++]=i;
ans+=rule[first];
return;
}
inline void findPress(){
string x,y;
x=ans+rule[p[1]];y=ans+rule[p[2]];
for(int i=0;i<3;i++)x+=y+rule[p[i]];
//cout<<x<<endl;
ans+=rule[p[press(x)-ans.size()]];
return;
}
inline void findLast(){
string x,y;
x=ans+rule[p[1]];y=ans+rule[p[2]];
//cout<<x<<" "<<y<<endl;
if(press(x)==ans.size()+1)ans=x;
else if(press(y)==ans.size()+1)ans=y;
else ans+=rule[p[0]];
return;
}
string guess_sequence(int n) {
findFirst();
for(int i=1;i<n-1;i++)findPress();
findLast();
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |