# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
99278 | wleung_bvg | 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.
//============================================================================
// Name : ioi18p1.cpp
// Author : Daxi the Taxi
// Version :
// Copyright : ALL YOUR CODE IS BELONG TO US
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> p;
#ifndef ONLINE_JUDGE
int press(string s);
#endif
string guess_sequence(int n){
string curr = "", usable = "";
// Guessing first letter
int ret = press("AB");
if(ret){
ret = press("A");
if(ret)
curr = "A", usable = "BXY";
else
curr = "B", usable = "AXY";
}
else{
ret = press("X");
if(ret)
curr = "X", usable = "ABY";
else
curr = "Y", usable = "ABX";
}
// Rest of it
for (int i = 1; i < n; ++i) {
ret = press(curr + usable[0] + curr + usable[1]);
if(ret > i){
ret = press(curr + usable[0]);
if(ret > i)
curr += usable[0];
else
curr += usable[1];
}
else
curr += usable[2];
}
return curr;
}
#ifndef ONLINE_JUDGE
const int N = 5;
const string STR = "ABXYY";
int press(string s){
int sz = s.length(), ptr = 0, best = INT_MIN;
for (int i = 0; i < sz; ++i) {
if(s[i] == STR[ptr])
ptr++;
else
ptr = 0;
best = max(best, ptr);
}
return best;
}
int main(){
printf("%s\n", guess_sequence(N).c_str());
return 0;
}
#endif