# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
139459 | Meloric | Combo (IOI18_combo) | C++14 | 1 ms | 244 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>
using namespace std;
int turn(string known, string pos){
string a = "";
for(char b : known){
a+=b;
}
a+=pos[1];
for(int i = 0; i< 3; i++){
for(char b : known){
a+= b;
}
a+=pos[2];
a+=pos[i];
}
//cout << a << '\n';
return press(a);
}
char beg(string pos){
//cout << pos << "pos"<<'\n';
if(pos.size()==1)return pos[0];
string a = "";
for(int i = 0; i< pos.size()/2; i++){
a += pos[i];
}
//cout << a << '\n';
int num = press(a);
if(num > 0){
return beg(a);
}else{
string b = "";
for(int i = pos.size()/2; i < pos.size(); i++){
b+=pos[i];
}
return beg(b);
}
}
string guess_sequence(int N) {
string but = "ABXY";
string known = "";
known+=beg(but);
string pos ="";
for(auto c : but){
if(c == known[0])continue;
pos+=c;
}
//cout << pos;
for(int i = 1; i< N-1; i++){
int ans = turn(known, pos);
int tmp = ans-known.size();
if(tmp == 0)known+=pos[0];
if(tmp == 1)known+=pos[1];
if(tmp == 2)known+=pos[2];
assert(tmp<=2);
}
//cout << known+pos[0]<<'\n';
//cout << known+pos[1]<<'\n';
if(press(known+pos[0])==N){
//assert(known.size()+1 == N);
return known+pos[0];
}
if(press(known+pos[1])==N){
//assert(known.size()+1 == N);
return known+pos[1];
}
//assert(known.size()+1 == N);
return known+pos[2];
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |