제출 #1359683

#제출 시각아이디문제언어결과실행 시간메모리
1359683osmiyum콤보 (IOI18_combo)C++20
100 / 100
6 ms484 KiB
#include "combo.h"
#include <bits/stdc++.h>

using namespace std;

string guess_sequence(int N) {
    string s = "";
    int n = N;

    // 1. İLK KARAKTERİ BUL (Maks 2 hamle)
    if (press("AB")) {
        if (press("A")) s = "A";
        else s = "B";
    } else {
        if (press("X")) s = "X";
        else s = "Y";
    }

    if (n == 1) return s;

    // Kalan karakterleri belirle
    string chars = "";
    string all = "ABXY";
    for (char c : all) {
        if (c != s[0]) chars += c;
    }

    // 2. ORTA KARAKTERLERİ BUL (n-2 hamle)
    // i=2'den n-1'e kadar (son karakter hariç)
    for (int i = 2; i < n; i++) {
        // uret = (s+chars[0]) + (s+chars[1]+chars[0]) + (s+chars[1]+chars[1]) + (s+chars[1]+chars[2])
        string uret = s + chars[1] + s + chars[2] + chars[0] + s + chars[2] + chars[1] + s + chars[2] + chars[2];
        
        int val = press(uret);
        
        if (val == i) {
            s += chars[1];
        } else if (val == i + 1) {
            s += chars[2];
        } else {
            s += chars[0];
        }
    }

    // 3. SON KARAKTERİ BUL (Maks 2 hamle)
    if (press(s + chars[0]) == n) {
        s += chars[0];
    } else if (press(s + chars[1]) == n) {
        s += chars[1];
    } else {
        s += chars[2];
    }

    return s;
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…