# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
574555 | KrisjanisP | Combo (IOI18_combo) | C++14 | 35 ms | 688 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;
typedef long long ll;
string guess_sequence(int N) {
string res = "";
if(press("AB")>=1)
{
if(press("A")==1) res="A";
else res="B";
}
else
{
if(press("X")==1) res="X";
else res="Y";
}
if(N==1) return res;
char a[4] = {'A','B','X','Y'};
for(ll i=1;i<N-1;i++)
{
string query = "";
char f, s;
for(ll j=0;j<4;j++)
{
if(a[j]==res[0]) continue;
query += res;
query += a[j];
f = a[j];
break;
}
for(ll j=0;j<4;j++)
{
if(a[j]==res[0]||a[j]==f) continue;
for(ll k=0;k<4;k++)
{
if(a[k]==res[0]) continue;
query+=res;
query+=a[j];
query+=a[k];
}
s = a[j];
break;
}
ll w = press(query);
if(w==(ll)res.size())
{
for(ll j=0;j<4;j++)
{
if(a[j]==res[0]||a[j]==f||a[j]==s) continue;
res += a[j];
break;
}
}
else if(w==(ll)res.size()+1)
{
res += f;
}
else if(w==(ll)res.size()+2)
{
res += s;
}
}
bool found = false;
for(ll i=0;i<3;i++)
{
if(a[i]==res[0]) continue;
ll w = press(res+a[i]);
if(w!=N) continue;
found = true;
res += a[i];
break;
}
if(!found) res+=a[3];
return res;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |