# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
152522 | ivandasfs | Combo (IOI18_combo) | C++14 | 1 ms | 256 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 <iostream>
#include <algorithm>
#include <set>
using namespace std;
set <char> b;
char c[3];
int press(string s);
/*
string ans = "ABXXY";
int press(string s) {
int sol = 0;
for (int i=0 ; i<s.size() ; i++) {
if (s[i] == ans[0]) {
int br = 0;
for (int j=0 ; j < ans.size() and i + j < s.size() ; j++) {
if (ans[j] == s[i+j]) br++;
else break;
}
sol = max(sol, br);
}
}
return sol;
}
*/
string guess_sequence(int n) {
b.insert('A');
b.insert('B');
b.insert('X');
b.insert('Y');
string sol = "";
if (press("AB"))
if (press("A"))
sol += 'A';
else
sol += 'B';
else
if (press("C"))
sol += 'C';
else
sol += 'D';
if (n==1) return sol;
b.erase(b.find(sol[0]));
int i = 0;
for (set<char> :: iterator it = b.begin() ; it!=b.end() ; it++) {
c[i++] = *it;
}
for (int i=1 ; i<n-1 ; i++) {
int br = press(sol+c[0] + sol+c[1]+c[0] + sol+c[1]+c[1] + sol+c[1]+c[2]);
if (br == sol.size() + 0) sol += c[2];
else if (br == sol.size() + 1) sol += c[0];
else sol += c[1];
}
if (press(sol+c[0]) == n)
sol += c[0];
else
if (press(sol+c[1]) == n)
sol += c[1];
else
sol += c[2];
return sol;
}
/*
int main() {
cout <<guess_sequence(5)<<endl;
return 0;
}
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |