QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#192290#3125. Dango MakerCamillus#Compile Error//C++202.4kb2023-09-30 14:10:192024-07-04 02:13:15

Judging History

你现在查看的是最新测评结果

  • [2024-07-04 02:13:15]
  • 评测
  • [2023-09-30 14:10:19]
  • 提交

answer

#include "bits/stdc++.h"
using namespace std;

char t[3000][3000];
bool used[3000][3000];
int sum[3000][3000];

struct Data {
    int i1 = 0, j1 = 0;
    int i2 = 0, j2 = 0;
    int i3 = 0, j3 = 0;

    Data() = default;

    static constexpr int H = 0;
    static constexpr int V = 1;

    Data(int i, int j, int t) {
        if (t == H) {
            tie(i1, j1) = tuple(i, j);
            tie(i2, j2) = tuple(i, j + 1);
            tie(i3, j3) = tuple(i, j + 2);
        } else {
            tie(i1, j1) = tuple(i, j);
            tie(i2, j2) = tuple(i + 1, j);
            tie(i3, j3) = tuple(i + 2, j); 
        }
    }

    bool check() const {
        return !used[i1][j1] && !used[i2][j2] && !used[i3][j3];
    }

    void set() const {
        used[i1][j1] = true;
        used[i2][j2] = true;
        used[i3][j3] = true;
    }

    void add() const {
        sum[i1][j1] += 1;
        sum[i2][j2] += 1;
        sum[i3][j3] += 1;
    }

    void del() const {
        sum[i1][j1] -= 1;
        sum[i2][j2] -= 1;
        sum[i3][j3] -= 1;
    }

    int get() const {
        return max(sum[i1][j1], sum[i2][j2], sum[i3][j3]);
    }
};

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> t[i][j];
        }
    }

    vector<Data> all;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (j + 2 < m && t[i][j] == 'R' && t[i][j + 1] == 'G' && t[i][j + 2] == 'W') {
                all.emplace_back(i, j, Data::H);
                all.back().add();
            }
            if (i + 2 < n && t[i][j] == 'R' && t[i + 1][j] == 'G' && t[i + 2][j] == 'W') {
                all.emplace_back(i, j, Data::V);
                all.back().add();
            }
        }
    }

    int ans = 0;

    while (!all.empty()) {
        auto it = min_element(all.begin(), all.end(), [](const auto &A, const auto &B) {
            return A.get() < B.get();
        });
        swap(*it, all.back());
        Data cur = all.back();
        all.pop_back();
        cur.del();
        if (cur.check()) {
            cur.set();
            ans += 1;
        }
    }

    cout << ans << '\n';
    return 0;
}

詳細信息

In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from answer.code:1:
/usr/include/c++/13/bits/stl_algobase.h: In instantiation of ‘constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare) [with _Tp = int; _Compare = int]’:
answer.code:53:19:   required from here
/usr/include/c++/13/bits/stl_algobase.h:306:17: error: ‘__comp’ cannot be used as a function
  306 |       if (__comp(__a, __b))
      |           ~~~~~~^~~~~~~~~~