Submission #1189895

#TimeUsernameProblemLanguageResultExecution timeMemory
1189895MatteoArcari콤보 (IOI18_combo)C++20
97 / 100
7 ms484 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;

int press (string p);

string guess_sequence(int n) {
    srand(time(nullptr));

    vector<int> ord = {0, 1, 2};
    
    string s = "";

    string chars;
    {
        if (press("A")) { s = "A"; chars = "BXY"; }
        else if (press("B")) { s = "B"; chars = "AXY"; }
        else if (press("X")) { s = "X"; chars = "ABY"; }
        else { s = "Y"; chars = "ABX"; }
    }

    for (int i = 1; i < n; i++) {
        random_shuffle(ord.begin(), ord.end());
        int x;
        if (i == n - 1) {
            x = press(s + chars[0]);
            if (x == n) { s += chars[0]; break; }
            x = press(s + chars[1]);
            if (x == n) { s += chars[1]; break; }
            s += chars[2]; break;
        }
        
        char c0 = chars[ord[0]];
        char c1 = chars[ord[1]];
        char c2 = chars[ord[2]];

        string p = s + c0 + c0 + s + c0 + c1 + s + c0 + c2 + s + c1;
        x = press(p);
        if (x == i + 2) s += c0;
        if (x == i + 1) s += c1;
        if (x == i + 0) s += c2;
    }

    return s;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...