Submission #538254

#TimeUsernameProblemLanguageResultExecution timeMemory
538254EZiganshinCombo (IOI18_combo)C++17
100 / 100
27 ms592 KiB
#include "combo.h"
#include <bits/stdc++.h>

#include <random>

using namespace std;

const int K = 4;

vector<string> k = {"A", "B", "X", "Y"};

string get_string(vector<int> &a) {
    string res;
    for (int x: a) {
        res += k[x];
    }
    return res;
}

int n;

string guess_sequence(int N) {
    n = N;
    string s;
    if (press(k[0] + k[1])) {
        if (press(k[0])) {
            s = k[0];
        } else {
            s = k[1];
        }
    } else {
        if (press(k[2])) {
            s = k[2];
        } else {
            s = k[3];
        }
    }
    for (int i = 0; i < 4; i++) {
        if (k[i] == s) {
            k.erase(k.begin() + i);
        }
    }
    for (int i = 1; i < n - 1; i++) {
        int x = press(s + k[0] + k[0] + s + k[0] + k[1] + s + k[0] + k[2] + s + k[1]);
        if (x == i) {
            s += k[2];
        } else if (x == i + 1) {
            s += k[1];
        } else {
            s += k[0];
        }
    }
    if (n > 1) {
        if (press(s + k[0]) == n) {
            s += k[0];
        } else if (press(s + k[1]) == n) {
            s += k[1];
        } else {
            s += k[2];
        }
    }
    return s;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...