제출 #1023361

#제출 시각아이디문제언어결과실행 시간메모리
1023361vaneaCombo (IOI18_combo)C++14
0 / 100
1 ms344 KiB
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;
using ll = long long;

string guess_sequence(int n) {
    vector<string> pos = {"A", "B", "X", "Y"};
    string ans = "";
    if(press("AB")) {
        if(press("A")) ans += "A";
        else ans += "B";
    }
    else {
        if(press("X")) ans += "X";
        else ans += "Y";
    }
    string res = to_string(ans[0]);
    for(int i = 1; i < n; i++) {
        if(i == n-1) {
            string curr = "";
            string last;
            for(auto it : pos) {
                if(it == res) continue;
                if(curr.length() == 2) {
                    last = it;
                }
                else curr += it;
            }
            if(press(curr)) {
                string curr1 = to_string(curr[0]), curr2 = to_string(curr[1]);
                if(press(curr1)) ans += curr1;
                else ans += curr2;
            }
            else ans += last;
        }
        else {
            string f = "", s = "", t = "";
            for(auto it : pos) {
                if(it == res) continue;
                if(f == "") f = it;
                else if(s == "") s = it;
                else t = it;
            }
            string curr = ans + f + s + ans + f + f + ans + f + t + ans + s;
            int k = press(curr);
            if(k == 2) {
                ans += f;
            }
            else if(k == 1) {
                ans += s;
            }
            else ans += t;
        }
    }
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...