제출 #703394

#제출 시각아이디문제언어결과실행 시간메모리
703394SamNguyen콤보 (IOI18_combo)C++14
30 / 100
50 ms544 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;

namespace SUB1 {
    string guess_sequence(int N) {
        string ans = "";
        for (int i = 0; i < N; i++) {
            for (char c : {'A', 'B', 'X', 'Y'}) {
                ans.push_back(c);
                if (press(ans) == i + 1)
                    break;
                ans.pop_back();
            }
        }

        return ans;
    }
}

namespace SUB2 {
    string chars = "ABXY";

    string guess_sequence(int N) {
        string ans = "";
        for (int i = 0; i < N; i++) {
            int cnt = 0;
            for (auto it = chars.begin(); it != chars.end(); it++) {
                char c = *it;
                if (not ans.empty() and c == ans.front())
                    continue;

                cnt++;
                ans.push_back(c);

                if (i == 0 and cnt == 4)
                    break;
                if (i > 0 and cnt == 3)
                    break;

                if (press(ans) == i + 1)
                    break;
                ans.pop_back();
            }
        }

        return ans;
    }
}

string guess_sequence(int N) {
    if (N == 3)
        return SUB1::guess_sequence(N);

    return SUB2::guess_sequence(N);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...