제출 #1211318

#제출 시각아이디문제언어결과실행 시간메모리
1211318lukasuliashvili콤보 (IOI18_combo)C++20
0 / 100
0 ms408 KiB
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;

string guess_sequence(int N) {
    string all = "ABXY";
    string p;

    // Safely guess the first character
    for (char c : all) {
        if (press(string(1, c)) == 1) {
            p += c;
            break;
        }
    }

    // Assign the other 3 letters
    string rest;
    for (char c : all) {
        if (c != p[0]) rest += c;
    }

    string fix1 = string(1, rest[0]);
    string fix2 = string(1, rest[1]);
    string fix3 = string(1, rest[2]);

    // Loop to guess remaining characters
    while (p.size() < N) {
        string q = p + fix1 + p + fix2 + fix3 + p + fix2 + fix1 + p + fix2 + fix2;
        int res = press(q);
        if (res == p.size()) {
            p += fix3;
        } else if (res == p.size() + 1) {
            p += fix1;
        } else {
            p += fix2;
        }
    }

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