# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1006959 | devariaota | Combo (IOI18_combo) | C++17 | 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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define fi first
#define se second
#define endl '\n'
template <typename T>
using ordered_set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
int n;
string guess_sequence(int n){
string p = "AB", s = "";
if(press(p)){
p = "A";
if(press(p)) s += p;
else s += "B";
} else {
p = "X";
if(press(p)) s += p;
else s += "Y";
}
vector<char> ch;
if(s[0] != 'A') ch.push_back('A');
if(s[0] != 'B') ch.push_back('B');
if(s[0] != 'X') ch.push_back('X');
if(s[0] != 'Y') ch.push_back('Y');
if(n % 2 == 0){
p = "";
p += s;
p += ch[0];
p += s;
p += ch[1];
if(press(p)){
p = s + ch[0];
if(press(p)){
s += ch[0];
} else {
s += ch[1];
}
} else {
s += ch[2];
}
}
while(s.length() + 2 <= n){
p = "";
for(int i = 0; i < 3; i++){
p += s;
p += s[0];
p += ch[i];
}
p += s;
p += ch[1];
if(press(p) == s.length() + 2){
s += ch[0];
} else if(press(p) == s.length() + 1){
s += ch[1];
} else {
s += ch[2];
}
}
return s;
}