# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
636559 | Son | Combo (IOI18_combo) | C++14 | 30 ms | 640 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 <bits/stdc++.h>
#include "combo.h"
using namespace std;
string guess_sequence( int N ){
vector < char > V;
V.push_back('A');
V.push_back('B');
V.push_back('Y');
V.push_back('X');
string ans = "";
int ab = press("AB");
if ( ab == 2 ){
ans = "AB";
} else if ( ab == 1 ){
ab = press("A");
if ( ab == 1 ) ans = "A";
else ans = "B";
} else {
int xy = press("X");
if ( xy == 1 ) ans = "X";
else ans = "Y";
}
int ch;
vector < char > W;
for ( int i = 0; i < V.size(); i++ ){
if ( V[i] == ans[0] ){
ch = i;
} else {
W.push_back(V[i]);
}
}
while ( (int)(ans.size()) < N ){
int prevN = (int)(ans.size());
if ( N - prevN == 1 ){
string t = ans + W[0];
if ( press(t) == prevN + 1 ){
ans += W[0];
} else {
t = ans + W[1];
if ( press(t) == prevN + 1 ){
ans += W[1];
} else {
ans += W[2];
}
}
} else {
string t = ans + W[0];
t += ans + W[1]+ "" + W[0];
t += ans + W[1]+ "" + W[1];
t += ans + W[1]+ "" + W[2];
int pt = press(t);
if ( pt == prevN ){
ans += W[2];
} else if ( pt == prevN + 1 ){
ans += W[0];
} else {
ans += W[1];
}
}
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |