# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
79484 | alextodoran | Combo (IOI18_combo) | C++14 | 49 ms | 524 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 <bits/stdc++.h>
#include "combo.h"
using namespace std;
/*
string combo;
int press(string p)
{
for(int i = 0; i < combo.size(); i++)
{
int ok1 = 0;
for(int j = 0; j < p.size() - i; j++)
{
int ok = 1;
for(int k = j; k <= j + i; k++)
if(p[k] != combo[k - j])
{
ok = 0;
break;
}
if(ok == 1)
{
ok1 = 1;
break;
}
}
if(ok1 == 0)
return i;
}
return combo.size();
}*/
string guess_sequence(int N)
{
string b[] = {"A", "B", "X", "Y"};
vector <string> b1;
b1.clear();
string pref = "";
if(press("AX"))
{
if(press("A"))
pref = "A";
else
pref = "X";
}
else
{
if(press("B"))
pref = "B";
else
pref = "Y";
}
for(int i = 0; i < 4; i++)
if(b[i] != pref)
b1.push_back(b[i]);
for(int i = 1; i < N - 1; i++)
{
int q = press(pref + b1[0] + pref + b1[1] + b1[0] + pref + b1[1] + b1[1] + pref + b1[1] + b1[2]);
if(q == pref.size())
pref += b1[2];
else if(q == pref.size() + 1)
pref += b1[0];
else
pref += b1[1];
}
if(N == 1)
return pref;
if(press(pref + b1[0] + pref + b1[1]) > pref.size())
{
if(press(pref + b1[0]) > pref.size())
pref += b1[0];
else
pref += b1[1];
}
else
pref += b1[2];
return pref;
}
/*
int main()
{
cin >> combo;
cout << guess_sequence(combo.size());
return 0;
}*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |