UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#212920#775. cKevinhwbbCompile Error//C++1.9kb2024-10-21 16:37:322024-10-21 16:37:33

answer

#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>

using namespace std;

// 判断数组是否单调不下降
bool is_non_decreasing(const vector<int>& arr) {
    for (size_t i = 1; i < arr.size(); ++i) {
        if (arr[i] < arr[i - 1]) return false;
    }
    return true;
}

// 判断数组是否单调
bool is_monotonic(const vector<int>& arr) {
    bool increasing = true, decreasing = true;
    for (size_t i = 1; i < arr.size(); ++i) {
        if (arr[i] > arr[i - 1]) increasing = false;
        if (arr[i] < arr[i - 1]) decreasing = false;
        if (!increasing && !decreasing) return false;
    }
    return true;
}

// 预处理函数,返回区间 [l, r] 是否必胜
bool preprocess(const vector<int>& arr, int l, int r, int type) {
    if (type == 1) return is_non_decreasing(arr);
    else return is_monotonic(arr);
}

// 动态规划解决博弈问题
string solve(const vector<int>& arr, int l, int r, int type) {
    if (preprocess(arr, l, r, type)) return "Bob";
    int n = r - l + 1;
    vector<vector<bool>> dp(n, vector<bool>(n, false));
    for (int len = 1; len <= n; ++len) {
        for (int i = 0; i <= n - len; ++i) {
            int j = i + len - 1;
            if (preprocess(arr, l + i, l + j, type)) {
                dp[i][j] = true;
            } else {
                for (int k = i; k < j; ++k) {
                    if (!dp[i][k] && !dp[k + 1][j]) {
                        dp[i][j] = true;
                        break;
                    }
                }
            }
        }
    }
    return dp[0][n - 1] ? "Alice" : "Bob";
}

int main() {
    int n, type;
    cin >> n >> type;
    vector<int> arr(n);
    for (int& a : arr) cin >> a;
    int m;
    cin >> m;
    for (int i = 0; i < m; ++i) {
        int l, r;
        cin >> l >> r;
        cout << solve(arr, l - 1, r - 1, type) << endl;
    }
    return 0;
}

Details

In file included from /usr/include/c++/4.8/unordered_map:35:0,
                 from answer.code:4:
/usr/include/c++/4.8/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support for the \
  ^
answer.code: In function 'std::string solve(const std::vector<int>&, int, i...