# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
484811 | MohamedFaresNebili | Combo (IOI18_combo) | C++14 | 0 ms | 0 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>
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
#include "combo.h"
using namespace std;
using ll = long long;
using vi = vector<int>;
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define all(x) (x).begin() , (x).end()
string guess_sequence(int N) {
string lett = "ABXY";
string p = ""; int first = -1;
for(int l = 0; l < 3; l++) {
p = "";
for (int i = 0; i < N; ++i) p += lett[l];
if(press(p)) {
first = l;
break;
}
}
if(first == -1) { first = 3; p[0] = lett[3]; }
for(int i = 1; i < N; i++) {
bool found = 0;
for(int l = 0; l < 2; l++) {
if(l == first) continue;
p[i] = lett[l];
if(press(p) >= i+1) { found = 1; break; }
}
if(!found) {
if(first == 2) p[i] = lett[3];
else if(first == 3) p[i] = lett[2];
else {
p[i] = lett[2];
if(press(p) <= i) press[i] = lett[3];
}
}
}
return p;
}