제출 #1136865

#제출 시각아이디문제언어결과실행 시간메모리
1136865njoopCombo (IOI18_combo)C++20
0 / 100
0 ms408 KiB
#include "combo.h"
#include <bits/stdc++.h>

using namespace std;

string guess_sequence(int n) {
    char f, a, b, c;
    int val;
    string ans, t;
    val = press("AB");
    if(val) {
        a = 'X';
        b = 'Y';
        val = press("A");
        f = (val ? 'A' : 'B');
        c = (!val ? 'A' : 'B');
    } else {
        a = 'A';
        b = 'B';
        val = press("X");
        f = (val ? 'X' : 'Y');
        c = (!val ? 'X' : 'Y');
    }
    ans.push_back(f);
    for(int i=2; i<n; i++) {
        t.clear();
        t += ans + a + b;
        t += ans + a + c;
        t += ans + b;
        val = press(t);
        if(val == i+1) {
            ans.push_back(a);
        }  else if(val == i) {
            ans.push_back(b);
        } else {
            ans.push_back(c);
        }
    }
    val = press(ans + a);
    if(val == n) return ans + a;
    val = press(ans + b);
    if(val == n) return ans + b;
    return ans + c;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...