# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
600549 | Belgutei | Combo (IOI18_combo) | C++17 | 56 ms | 620 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 "combo.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
char a[3000];
string p;
string s;
void go(char ch) {
int cnt = 0;
s += ch;
if(ch != 'A') { a[cnt] = 'A'; cnt ++; }
if(ch != 'B') { a[cnt] = 'B'; cnt ++; }
if(ch != 'X') { a[cnt] = 'X'; cnt ++; }
if(ch != 'Y') { a[cnt] = 'Y'; cnt ++; }
}
std::string guess_sequence(int N) {
int c = press("AB");
if(c == 2) {
s += p;
go('A');
} else if(c == 1) {
c = press("A");
if(c == 1) go('A');
else go('B');
} else {
if(press("X") == 1) go('X');
else go('Y');
}
if(s.size() == N) return s;
for(int i = s.size() + 1; i < N; i ++) {
p = s + a[0] + a[1] + s + a[0] + a[2] + s + a[0] + a[0] + s + a[1];
c = press(p);
if(c == s.size() + 2) s += a[0];
else if(c == s.size() + 1) s += a[1];
else s += a[2];
}
p = s + a[0];
if(press(p) == N) return p;
p = s + a[1];
if(press(p) == N) return p;
p = s + a[2];
return p;
// std::string p = "";
// for (int i = 0; i < 4 * N; ++i) {
// p += 'A';
// }
// int coins = press(p);
// std::string S = "";
// for (int i = 0; i < N; ++i) {
// S += 'A';
// }
// return S;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |