# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1020724 | ZanP | Combo (IOI18_combo) | C++14 | 1 ms | 344 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 <string>
#include <vector>
#include <algorithm>
using namespace std;
int press(string p);
// {
// cout << p << '\n';
// int a; cin >> a;
// return a;
// }
int n;
string z;
string p;
void make_bases()
{
if(z[0] == 'A'){
p = "XYB";
} else if(z[0] == 'B') {
p = "AXY";
} else if(z[0] == 'X'){
p = "ABY";
} else if(z[0] == 'Y'){
p = "ABX";
}
}
string guess_sequence(int N)
{
n = N;
z.reserve(n);
int a = press("AB");
if(a == 2){z = "AB";}
else if(a == 1){
if(press("A")){
z = "A";
}else{
z = "B";
}
}else{
if(press("X")){
z = "X";
}else{
z = "Y";
}
}
make_bases();
while(z.size() < n-1)
{
string ask = z;
ask.push_back(p[0]);
for (int i = 0; i<3;i++){
ask.append(z);
ask.push_back(p[1]);
ask.push_back(p[i]);
}
a = press(ask);
if(a == z.size())
{
z.push_back(p[2]);
}
else if(a == z.size()+1)
{
z.push_back(p[0]);
}
else
{
z.push_back(p[1]);
}
}
for (int i = 0; i<2; i++)
{
string ask = z;
ask.push_back(p[i]);
a = press(ask);
if(a == n) return ask;
}
z.push_back(p[2]);
return z;
}
// int main()
// {
// int x; cin >> x; cout << guess_sequence(x) << '\n';
// return 0;
// }
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |