# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1022228 | khome | Combo (IOI18_combo) | C++17 | 804 ms | 262148 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> a;
a={'A', 'B', 'X','Y'};
string res, cur;
char per;
int ab = press("AB"), bx = press("BX"), id;
if (ab == 1) {
if (bx == 1) {per = 'B'; id = 1; res += per;}
if (bx == 2) {per = 'B'; id = 1; res += "BX";}
if (bx == 0) {per = 'A'; id = 0; res += per;}
}
else if (ab == 0) {
if (bx == 1) {per = 'X'; id = 2;}
else {per = 'Y'; id = 3;}
res += per;
}
else if (ab == 2) {per = 'A'; id = 0; res = "AB";}
int n = res.size();
if (n==1){
if (press(res + a[(id+1)%4] + res + a[(id+2)%4]) == 2) { // id == 3 res = "Y"; press("YAYB") == 1;
if (press(res + a[(id+1)%4]) == 2) {res += a[(id+1)%4];}
else res += a[(id+2)%4];
}
else { // press("YAYB") == 0;
res += a[(id+3)%4];
}
}
n = res.size();
while (n!=N){
// int ij = -1;
for (char i : a){
// ij++;
n = res.size();
if (n == N) break;
if (i != per && i!= res[-1]){
cur = res;
// cout << "current = " << res << ' ';
while (res.size()!=N) res+=i;
// cout << "now = " << res << ' ';
int r = press(res);
// cout << "r = " << r << " n = " << n << ' ';
if (r > n){
cur = "";
for (int j = 0; j < r; j++){
cur += res[j];
}
// cout << "changed = " << cur;
res = cur;
// cout << "\n";
continue;
}
res = cur;
// cout << "\n";
}
}
}
//XYABABYBA
//XYAXYBBXYBYXYBA
// int i = 0;
// if (a[i] != per){ // i = 0 == > a[i] == "A";
// if (press(res+a[i]+res+a[(i+1)%4]) == 2){ // press("YAYB") == 1;
// if (press(res+a[(i+2)%4]+res+a[(i+1)%4]) == 2) res += a[(i+1)%4];
// // press("YXYB") == 1;
// else res += a[i]; //press("YXYB") == 0;
// }
// else res += a[(i+2)%4];
// }
// cout << res << "\n";
// while (res.size()!=N){
// n = res.size();
// }
return res;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |