# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
859766 | dsyz | Combo (IOI18_combo) | C++17 | 15 ms | 1932 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;
using ll = long long;
#define MAXN (1000005)
std::string guess_sequence(int N) {
string p = "AB";
ll res = press(p);
char firstchar = ' ';
if(res >= 1){
p = "A";
res = press(p);
if(res >= 1){
firstchar = 'A';
}else{
firstchar = 'B';
}
}else{
p = "X";
res = press(p);
if(res >= 1){
firstchar = 'X';
}else{
firstchar = 'Y';
}
}
string ans = "";
ans.push_back(firstchar);
vector<char> choices;
if(firstchar != 'A') choices.push_back('A');
if(firstchar != 'B') choices.push_back('B');
if(firstchar != 'X') choices.push_back('X');
if(firstchar != 'Y') choices.push_back('Y');
for(ll i = 1;i < N - 1;i++){
p = ans + choices[0] + choices[0];
p += ans + choices[0] + choices[1];
p += ans + choices[0] + choices[2];
p += ans + choices[1];
res = press(p);
if(res == ans.size() + 2){
ans.push_back(choices[0]);
}else if(res == ans.size() + 1){
ans.push_back(choices[1]);
}else if(res == ans.size()){
ans.push_back(choices[2]);
}
}
if(N > 1){
p = ans + choices[0];
res = press(p);
if(res == N){
ans.push_back(choices[0]);
return ans;
}
p = ans + choices[1];
res = press(p);
if(res == N){
ans.push_back(choices[1]);
return ans;
}
ans.push_back(choices[2]);
return ans;
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |