제출 #749658

#제출 시각아이디문제언어결과실행 시간메모리
749658tamyte콤보 (IOI18_combo)C++14
100 / 100
29 ms576 KiB
#include<bits/stdc++.h>
#include "combo.h"
using namespace std;
const string code = "ABXYY";
// int press(string s) {
//     int ans = 0;
//     // cerr << "a";
//     for (int i = 0; i < s.size();) {
//         int j = i, ptr = 0;
//         while (j < s.size() && code[ptr] == s[j]) {
//             j++; ptr++;
//         }
//         i = max(j, i + 1);
//         // cerr << s << " " << ptr << "\n";
//         ans = max(ans, ptr);
//     }
//     return ans;
// }


string guess_sequence(int N) {
    vector<char> el = {'A', 'B', 'X', 'Y'};
    vector<char> fin;
    string ans = "";
    string c = "AB";
    if (!press(c)) {
        c = "XY";
    }
    if (!press(c.substr(0, 1))) {
        c = c[1];
    } else {
        c = c[0];
    }
    ans += c;
    for (auto u : el) {
        if (u != c[0]) {
            fin.push_back(u);
        }
    }
    for (int i = 2; i < N; ++i) {
        string guess = ans + fin[0] + fin[0] + ans + fin[0] + fin[1] +
            ans + fin[0] + fin[2] + ans + fin[1];
        int num = press(guess);
        if (num == i - 1) {
            ans += fin[2];
        } else if (num == i) {
            ans += fin[1];
        } else {
            ans += fin[0];
        }
    }
    if (N > 1) {
        if (press(ans + fin[0]) == N) {
            ans += fin[0];
        } else if (press(ans + fin[1]) == N) {
            ans += fin[1];
        } else {
            ans += fin[2];
        }
    }
    return ans;
}


// int main () {
//     cout << guess_sequence(code.size());
// }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...