# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
569454 | NemanjaSo2005 | Combo (IOI18_combo) | C++14 | 51 ms | 636 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 ll long long
using namespace std;
char ps,slovo[5]={' ','A','B','X','Y'};
string tmp,nasli;
ll Ng,bp;
int pritisni(string x){
bp++;
if(bp>8000)
exit(-1);
if(x.size()>Ng*4)
exit(-2);
int len=x.size();
for (int i = 0; i < len; ++i) {
if (x[i] != 'A' && x[i] != 'B' && x[i] != 'X' && x[i] != 'Y') {
exit(-1);
}
}
return press(x);
}
string guess_sequence(int N) {
Ng=N;
if(pritisni("AB")){
if(pritisni("A"))
ps='A';
else
ps='B';
}
else{
if(pritisni("X"))
ps='X';
else
ps='Y';
}
for(int i=1;i<=3;i++){
if(slovo[i]==ps){
for(int j=i;j<=3;j++)
slovo[j]=slovo[j+1];
break;
}
}
nasli.push_back(ps);
if(N==1){
return nasli;
}
for(int i=2;i<N;i++){
tmp.clear();
tmp+=nasli;
tmp.push_back(slovo[1]);
tmp.push_back(slovo[1]);
tmp+=nasli;
tmp.push_back(slovo[1]);
tmp.push_back(slovo[2]);
tmp+=nasli;
tmp.push_back(slovo[1]);
tmp.push_back(slovo[3]);
tmp+=nasli;
tmp.push_back(slovo[2]);
int vred=pritisni(tmp);
if(vred==(int)nasli.size()+2)
nasli.push_back(slovo[1]);
else if(vred==(int)nasli.size()+1)
nasli.push_back(slovo[2]);
else
nasli.push_back(slovo[3]);
}
tmp=nasli;
tmp.push_back(slovo[1]);
if(pritisni(tmp)==N)
return tmp;
tmp=nasli;
tmp.push_back(slovo[2]);
if(pritisni(tmp)==N)
return tmp;
nasli.push_back(slovo[3]);
return nasli;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |