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"
#define foreach for
#define in :
using namespace std;
typedef long long ll;
const int MODULO = 12;
template<class X , class Y>
bool Maximize(X &x , Y y)
{
if(x < y)
{
x = y;
return true;
}
return false;
}
template<class X ,class Y>
bool Minimize(X &x , Y y)
{
if(x > y)
{
x = y;
return true;
}
return false;
}
template<class X ,class Y>
void Add(X &x , Y y)
{
x += y;
if(x >= MODULO) x-= MODULO;
}
template<class X ,class Y>
void Sub(X & x , Y y)
{
x -= y;
if(x < 0 ) x += MODULO;
}
char dict[] = {'A' , 'B' , 'X' , 'Y'};
string guess_sequence(int n)
{
set<int>lefts;
for(int i = 0 ; i < 4 ; i++)
{
lefts.insert(i);
}
string p = "";
for(int i = 0 ; i < 4 ; i++ )
{
p += dict[i];
if(press(p))
{
p.pop_back();
continue;
}
p.pop_back();
lefts.erase(i);
}
p += dict[*lefts.begin()];
bool rights = true;
int maxx = 1;
while(rights)
{
rights = false;
foreach(int index in lefts)
{
p += dict[index];
if(Maximize(maxx , press(p)))
{
rights = true;
break;
}
p.pop_back();
}
}
rights = true;
while(rights)
{
rights = false;
foreach(int index in lefts)
{
reverse(p.begin() , p.end());
p += dict[index];
reverse(p.begin() , p.end());
if(Maximize(maxx , press(p)))
{
rights = true;
break;
}
reverse(p.begin() , p.end());
p.pop_back();
reverse(p.begin() , p .end());
}
}
assert((int)p.size() == n);
return p;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |