UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#212008#3815. 种树yangtianming001Compile Error//C++1.3kb2024-10-13 10:05:322024-10-13 12:54:42

answer

#include <bits/stdc++.h>
using namespace std;
bool f(const vector<pair<int, int>>& p, int n, int m) {
    vector<pair<int, int>> directions = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
    set<pair<int, int>> ps(p.begin(), p.end());

    for (const auto& pos : p) {
        int x = pos.first, y = pos.second;
        for (const auto& dir : directions) {
            int nx = x + dir.first;
            int ny = y + dir.second;
            if (ps.count({nx, ny})) {
                return false;  
            }
        }
    }
    return true;  
}


int main() {
    int n, m, k;
    cin >> n >> m >> k;
    if (k == 0) {
        return 1; 
    }
    vector<pair<int, int>> cells;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cells.emplace_back(i, j);
        }
    }

    int valid_count = 0;
    vector<bool> select(cells.size(), false);
    fill(select.begin(), select.begin() + k, true);  

    do {
        vector<pair<int, int>> a;
        for (int i = 0; i < cells.size(); ++i) {
            if (select[i]) {
                a.push_back(cells[i]);
            }
        }
        if (f(a, n, m)) {
            valid_count++;
        }
    } while (prev_permutation(select.begin(), select.end()));
    cout << valid_count<< endl;

    return 0;
}

详细

answer.code:3:34: error: '>>' should be '> >' within a nested template argument list
 bool f(const vector<pair<int, int>>& p, int n, int m) {\x0d
                                  ^
answer.code: In function 'bool f(const std::vector<std::pair<int, int> >&, int, int)':
answer.code:4:25: error: '>>' should be '> >' within a nested template argument list
     vector<pair<int, int>> directions = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};\x0d
                         ^
answer.code:4:74: error: in C++98 'direction...