# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
939817 | snpmrnhlol | Combo (IOI18_combo) | C++17 | 29 ms | 1864 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;
char v[4] = {'A','X','Y','B'};
string guess_sequence(int n){
string s = "";
string ans = "";
for(int i = 0;i < 2*n;i++)s+="A";
for(int i = 0;i < 2*n;i++)s+="X";
int a = press(s);
s.clear();
for(int i = 0;i < 2*n;i++)s+="A";
for(int i = 0;i < 2*n;i++)s+="Y";
int b = press(s);
if(a && b)ans+="A";
if(!a && b)ans+="Y";
if(a && !b)ans+="X";
if(!a && !b)ans+="B";
if(n == 1)return ans;
char c1,c2,c3;
for(int i = 0;i < 4;i++){
if(v[i] != ans[0]){
c1 = c2;
c2 = c3;
c3 = v[i];
}
}
for(int i = 0;i < n - 2;i++){
string g = "";
g+=ans;g+=c2;
g+=ans;g+=c3;g+=c1;
g+=ans;g+=c3;g+=c2;
g+=ans;g+=c3;g+=c3;
while(g.size() < 4*n)g+='A';
int nr = press(g);
if(nr == i + 1){
ans+=c1;
}else if(nr == i + 2){
ans+=c2;
}else{
ans+=c3;
}
}
string g = "";
g+=ans;g+=c1;
while(g.size() < 4*n)g+='A';
if(press(g) == n)ans+=c1;
else{
string g = "";
g+=ans;g+=c2;
while(g.size() < 4*n)g+='A';
if(press(g) == n)ans+=c2;
else ans+=c3;
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |