Submission #940883

#TimeUsernameProblemLanguageResultExecution timeMemory
940883LukapCombo (IOI18_combo)C++14
100 / 100
13 ms2052 KiB
#include "combo.h"
#include <bits/stdc++.h>

using namespace std;

//int press (string a) {
//    cout << a;
//    int b;
//    cin >> b;
//    return b;
//}

string guess_sequence(int n) {
    string rj = "";
    vector<string> svi {"A", "B", "X", "Y"};

    string poc;
    int a = press ("AB"), b;
    if (a) {
        b = press ("A");
        if (b) poc = "A";
        else poc = "B";
    }
    else {
        b = press ("X");
        if (b) poc = "X";
        else poc = "Y";
    }

    rj += poc;
    vector<string> ostali;
    for (auto it: svi) {
        if (it != poc) ostali.push_back(it);
    }
    int dul = rj.size ();
    if (dul == n) return rj;

    while (dul < n - 1) {
        string p = rj + ostali[0];
        for (int i = 0; i < 3; i++) p += rj + ostali[1] + ostali[i];

        int ret = press (p);

        if (ret == dul) rj += ostali[2];
        if (ret == dul + 1) rj += ostali[0];
        if (ret == dul + 2) rj += ostali[1];
        dul++;
    }

    if (press (rj + ostali[0]) == n) rj += ostali[0];
    else if (press (rj + ostali[1]) == n) rj += ostali[1];
    else rj += ostali[2];

    return rj;
}

//int main () {
//    int n;
//    cin >> n;
//    cout << guess_sequence (n);
//    return 0;
//}

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...