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;
vector<char> v = {'A', 'B', 'X', 'Y'};
char xth(int x, char ex) {
for(char i:v) {
if(i!=ex) {
x--;
if(x==0) return i;
}
}
}
std::string guess_sequence(int N) {
string ans;
if(press("AB")) {
if(press("A")) ans = "A";
else ans = "B";
} else {
if(press("X")) ans = "X";
else ans = "Y";
}
for(int i=2; i<N; i++) {
int tmp = press(ans + xth(1, ans[0]) + ans + xth(2, ans[0]) + xth(1, ans[0])
+ ans + xth(2, ans[0]) + xth(2, ans[0]) + ans + xth(2, ans[0]) + xth(3, ans[0]));
if(tmp==i) ans += xth(1, ans[0]);
else if(tmp==i+1) ans += xth(2, ans[0]);
else ans += xth(3, ans[0]);
}
if(N>1) {
if(press(ans + xth(1, ans[0]))==N) ans += xth(1, ans[0]);
else if(press(ans + xth(2, ans[0]))==N) ans += xth(2, ans[0]);
else ans += xth(3, ans[0]);
}
return ans;
}
Compilation message (stderr)
combo.cpp: In function 'char xth(int, char)':
combo.cpp:14:1: warning: control reaches end of non-void function [-Wreturn-type]
14 | }
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |