# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
574559 | KrisjanisP | Combo (IOI18_combo) | C++14 | 1 ms | 208 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) {
if(N==2)
{
ll w = press("AB");
if(w>=1)
{
if(w==2) return "AB";
else if(w==1)
{
if(press("AX")) return "AX";
else return "AY";
}
else{
w = press("BA");
if(w==2) return "BA";
else
{
if(press("BX")==2) return "BX";
else return "BY";
}
}
}
else
{
// XY
w = press("XA");
if(w==2) return "XA";
else if(w==1){
if(press("XB")==2) return "XB";
else return "XY";
}
else{
w = press("YA");
if(w==2) return "YA";
else
{
if(press("YB")==2) return "YB";
else return "YX";
}
}
}
}
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";
}
char a[4] = {'A','B','X','Y'};
for(ll i=res.size();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;
}
}
if(res.size()!=N)
{
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... |