# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
485501 | Joo | Combo (IOI18_combo) | C++17 | 30 ms | 676 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;
/*int press(string p){
cout << p << "\n";
int x; cin >> x; return x;
}*/
string guess_sequence(int N){
string str;
vector<char> a = {'A', 'B', 'X', 'Y'};
if(press("AB") == 0){ ///either x or y
if(press("X") == 1){
str += 'X';
a.erase(a.begin()+2);
}else{
str += 'Y';
a.erase(a.begin()+3);
}
}else{ ///either a or b
if(press("A") == 1){
str += 'A';
a.erase(a.begin());
}else{
str += 'B';
a.erase(a.begin()+1);
}
}
/*cout << "\n";
for(char x : a) cout << x << " ";
cout << "\n";*/
for(int i = 2; i < N; i++){
string tmp = str + a[1] + str + a[2] + a[0] + str + a[2] + a[1] + str + a[2] + a[2];
int res = press(tmp);
if(res == str.size()){ ///got nothing new
str += a[0];
}else if(res == str.size()+1){
str += a[1];
}else{
str += a[2];
}
}
if(str.size() < N){
if(press(str+a[0]) == N){
str += a[0];
}else if(press(str+a[1]) == N){
str += a[1];
}else{
str += a[2];
}
}
return str;
}
/*
int main(void){
int n; cin >> n;
cout << guess_sequence(n) << "\n";
return 0;
}
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |