Submission #775420

#TimeUsernameProblemLanguageResultExecution timeMemory
775420anha3k25cvpCombo (IOI18_combo)C++14
0 / 100
0 ms208 KiB
#include <bits/stdc++.h>
#include "combo.h"

using namespace std;

vector <int> vis, g;
char ch[] = {'A', 'B', 'X', 'Y'};

int check(string s, char c1, char c2) {
    s += c1;
    s += c2;
    return press(s);
}

int check(string s) {
    string s1 = s, s2 = s, s3 = s, s4 = s;
    s1 += ch[g[0]]; s1 += ch[g[0]];
    s2 += ch[g[0]]; s2 += ch[g[1]];
    s3 += ch[g[0]]; s3 += ch[g[2]];
    s4 += ch[g[1]];
    string p = s1 + s2 + s3 + s4;
    return press(p);
}

string guess_sequence(int N) {
    string ans;
    vis.assign(4, 0);
    int val = check(ans, ch[0], ch[1]);
    if (val) {
        val = check(ans, ch[0], ch[2]);
        if (val) {
            ans += ch[0];
            vis[0] = 1;
        }
        else {
            ans += ch[1];
            vis[1] = 1;
        }
    }
    else {
        val = check(ans, ch[0], ch[2]);
        if (val) {
            ans += ch[2];
            vis[2] = 1;
        }
        else {
            ans += ch[3];
            vis[3] = 1;
        }
    }
    for (int i = 0; i < 4; i ++)
        if (!vis[i])
            g.push_back(i);
    for (int i = 2; i < N; i ++) {
        val = check(ans);
        if (val == i + 1)
            ans += ch[g[0]];
        else if (val == i)
            ans += ch[g[1]];
        else
            ans += ch[g[2]];
    }
    val = check(ans, ch[g[0]], ch[g[1]]);
    if (val == N) {
        val = check(ans, ch[g[0]], ch[g[2]]);
        if (val == N)
            ans += ch[g[0]];
        else
            ans += ch[g[1]];
    }
    else
        ans += ch[g[2]];
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...