QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#155214#7119. Longest TriparbuzickCompile Error//C++204.6kb2023-09-01 14:06:272024-04-28 06:55:23

Judging History

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

  • [2024-04-28 06:55:23]
  • 管理员手动重测本题所有提交记录
  • [2023-09-01 14:06:27]
  • 评测
  • [2023-09-01 14:06:27]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

constexpr int maxn = 35;

int dp[maxn][maxn][maxn][maxn];

int biggest_stadium(int n, vector<vector<int>> f) {
    vector<vector<int>> pr_sum(n + 1, vector<int>(n + 1));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            f[i][j] ^= 1;
            pr_sum[i + 1][j + 1] = pr_sum[i + 1][j] + pr_sum[i][j + 1] - pr_sum[i][j] + f[i][j];
        }
    }
    if (pr_sum[n][n] == n * n - 1) {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                if (!f[i][j]) {
                    return n * n - min(i + 1, n - i) * min(j + 1, n - j);
                }
            }
        }
    }
    auto get = [&](int i1, int j1, int i2, int j2) {
        return pr_sum[i2][j2] - pr_sum[i1][j2] - pr_sum[i2][j1] + pr_sum[i1][j1];
    };
    if (n <= 30) {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                for (int l = 0; l < n; ++l) {
                    for (int r = l + 1; r <= n; ++r) {
                        dp[i][j][l][r] = 0;
                    }
                }
            }
        }
        int ans = 0;
        for (int i = 0; i < n; ++i) {
            for (int l = 0; l < n; ++l) {
                for (int r = l + 1; r <= n; ++r) {
                    if (get(i, l, i + 1, r) == r - l) {
                        dp[i][i][l][r] = r - l;
                        ans = max(ans, dp[i][i][l][r]);
                    }
                }
            }
        }
        for (int width = 1; width < n; ++width) {
            for (int i = 0; i + width <= n; ++i) {
                for (int l = 0; l < n; ++l) {
                    for (int r = l + 1; r <= n; ++r) {
                        if (dp[i][i + width - 1][l][r] == 0) {
                            continue;
                        }
                        for (int l2 = l; l2 < r; ++l2) {
                            for (int r2 = l2 + 1; r2 <= r; ++r2) {
                                if (i > 0 && get(i - 1, l2, i, r2) == r2 - l2) {
                                    dp[i - 1][i + width - 1][l2][r2] = max(dp[i - 1][i + width - 1][l2][r2], dp[i][i + width - 1][l][r] + r2 - l2);
                                    ans = max(ans, dp[i - 1][i + width - 1][l2][r2]);
                                }
                                if (i + width < n && get(i + width, l2, i + width + 1, r2) == r2 - l2) {
                                    dp[i][i + width][l2][r2] = max(dp[i][i + width][l2][r2], dp[i][i + width - 1][l][r] + r2 - l2);
                                    ans = max(ans, dp[i][i + width][l2][r2]);
                                }
                            }
                        }
                    }
                }
            }
        }
        return ans;
    }
    vector<vector<int>> ll(n, vector<int>(n, -1)), rr(n, vector<int>(n, n)), dd(n, vector<int>(n, n));
    for (int i = n - 1; i >= 0; --i) {
        for (int j = 0; j < n; ++j) {
            if (!f[i][j]) {
                ll[i][j] = j;
                dd[i][j] = i;
            } else {
                if (j > 0) {
                    ll[i][j] = ll[i][j - 1];
                }
                if (i + 1 < n) {
                    dd[i][j] = dd[i + 1][j];
                }
            }
        }
        for (int j = n - 1; j >= 0; --j) {
            if (!f[i][j]) {
                rr[i][j] = j;
            } else if (j + 1 < n) {
                rr[i][j] = rr[i][j + 1];
            }
        }
    }
    bool check = true;
    for (int i1 = 0; i1 < n; ++i1) {
        for (int j1 = 0; j1 < n; ++j1) {
            for (int i2 = 0; i2 < n; ++i2) {
                for (int j2 = 0; j2 < n; ++j2) {
                    if (!f[i1][j1] || !f[i2][j2]) {
                        continue;
                    }
                }
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (!f[i][j]) {
                continue;
            }
            int l = ll[i][j], r = rr[i][j], d = dd[i][j];
            if (get(i, 0, i + 1, l + 1) || get(d, j, n, j + 1) || get(i, r, i + 1, n)) {
                check = false;
            }
            if (l > -1 && d < n) {
                if (get(d, 0, n, l + 1)) {
                    check = false;
                }
            }
            if (r < n && d < n) {
                if (get(d, r, n, n)) {
                    check = false;
                }
            }
        }
    }
    if (check) {
        return pr_sum[n][n];
    } else {
        return pr_sum[n][n] - 1;
    }
}

详细

/usr/bin/ld: /tmp/ccJ0Lb2f.o: in function `main':
implementer.cpp:(.text.startup+0xa3): undefined reference to `longest_trip(int, int)'
collect2: error: ld returned 1 exit status