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;
vector <int> vis, g;
char ch[] = {'A', 'B', 'X', 'Y'};
int check(string s, char c1, char c2) {
string s1 = s, s2 = s;
s1 += c1;
s2 += c2;
s = s1 + s2;
return press(s);
}
int check(string s) {
string s1 = s, s2 = s, s3 = s, s4 = s;
s1 += ch[g[0]]; s1 += ch[g[0]];
s2 += ch[g[0]]; s2 += ch[g[1]];
s3 += ch[g[0]]; s3 += ch[g[2]];
s4 += ch[g[1]];
string p = s1 + s2 + s3 + s4;
return press(p);
}
string guess_sequence(int N) {
string ans;
vis.assign(4, 0);
int val = check(ans, ch[0], ch[1]);
if (val) {
val = check(ans, ch[0], ch[2]);
if (val) {
ans += ch[0];
vis[0] = 1;
}
else {
ans += ch[1];
vis[1] = 1;
}
}
else {
val = check(ans, ch[0], ch[2]);
if (val) {
ans += ch[2];
vis[2] = 1;
}
else {
ans += ch[3];
vis[3] = 1;
}
}
for (int i = 0; i < 4; i ++)
if (!vis[i])
g.push_back(i);
for (int i = 2; i < N; i ++) {
val = check(ans);
if (val == i + 1)
ans += ch[g[0]];
else if (val == i)
ans += ch[g[1]];
else
ans += ch[g[2]];
}
if (N > 1) {
val = check(ans, ch[g[0]], ch[g[1]]);
if (val == N) {
val = check(ans, ch[g[0]], ch[g[2]]);
if (val == N)
ans += ch[g[0]];
else
ans += ch[g[1]];
}
else
ans += ch[g[2]];
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |