QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#611944#9417. Palindromic Polygonshiqiaqiaya#Compile Error//C++173.7kb2024-10-05 00:34:402024-10-05 00:34:41

Judging History

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

  • [2024-10-05 00:34:41]
  • 评测
  • [2024-10-05 00:34:40]
  • 提交

answer

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define int long long
using i64 = long long;
using i128 = __int128;
mt19937_64 rd(time(0));
template <class K, class C = less<>> using paring_heap = __gnu_pbds::priority_queue<K, C>;
template <class K> using rb_tree = tree<K, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T, class ... A> void debug(const T & t, const A & ... a) { cerr << "[" << t, ((cerr << ", " << a), ...), cerr << "]\n"; }
const i64 mod = [](bool n) { return n ? 998244353 : 1e9 + 7; } (1);

const double pi = acos(-1);

struct point : array<int, 2> {   // int 遇到奇怪问题可重载各种比较符号
    int operator * (const point & t) { return at(0) * t[1] - at(1) * t[0]; }  // 叉积
    int operator / (const point & t) { return at(0) * t[0] + at(1) * t[1]; }  // 内积
    point & operator += (const point & t) { return at(0) += t[0], at(1) += t[1], *this; }
    point operator + (const point & t) { return point(*this) += t; }
    point & operator -= (const point & t) { return at(0) -= t[0], at(1) -= t[1], *this; }
    point operator - (const point & t) { return point(*this) -= t; }
    point & operator *= (const int & t) { return at(0) *= t, at(1) *= t, *this; }
    point operator * (const int & t) { return point(*this) *= t; }
    point & operator /= (const int & t) { return at(0) /= t, at(1) /= t, *this; }
    point operator / (const int & t) { return point(*this) /= t; }
};

void QAQ() {
    int n;
    cin >> n;

    vector<point> a(2 * n);
    vector<int> c(n);

    for (auto & x : c) {
        cin >> x;
    }
    c.resize(2 * n);
    for (int i = 0; i < n; i++) {
        cin >> a[i][0] >> a[i][1];
        c[i + n] = c[i];
        a[i + n] = a[i];
    }

    vector dp(2 * n, vector<array<int, 3>>(2 * n, {-1, -1, -1}));
    auto vis = dp;

    auto dfs = [&](auto && self, int l, int r, int op) -> int {
        if (l > r || vis[l][r][op] != -1) return dp[l][r][op];
        vis[l][r][op] = 0;
        if (l == r) return dp[l][r][op] = op == 2 ? 0 : -1;
        if (op == 2) {
            dp[l][r][op] = a[l] * a[r];
            for (int i = l + 1; i < r; i++) {
                auto t1 = self(self, i, r, 0), t2 = self(self, l, i, 1);
                if (t1 != -1) {
                    dp[l][r][op] = max(dp[l][r][op], a[l] * a[i] + t1);
                } if (t2 != -1) {
                    dp[l][r][op] = max(dp[l][r][op], a[i] * a[r] + t2);
                }
            }
        } else if (op == 0) {
            for (int i = l; i < r; i++) if (c[l] == c[i]) {
                auto t = self(self, l, i, 2);
                if (t != -1) {
                    dp[l][r][op] = max(dp[l][r][op], a[i] * a[r] + t);
                }
            }
        } else {
            for (int i = l + 1; i <= r; i++) if (c[i] == c[r]) {
                auto t = self(self, i, r, 2);
                if (t != -1) {
                    dp[l][r][op] = max(dp[l][r][op], a[l] * a[i] + t);
                }
            }
        }

        return dp[l][r][op];
    };

    int ans = 0;

    for (int i = 0; i < 2 * n; i++) {
        for (int j = i; j < 2 * n && (j - i + 1) <= n; j++) if (c[i] == c[j]) {
            auto t = dfs(dfs, i, j, 2);
            if (t != -1) {
                ans = max(ans, t + (a[j] - o) * a[i]);
            }
        }
    }

    cout << ans << "\n";
}

signed main() {
    cin.tie(0) -> sync_with_stdio(0);
    int t = 1;
    cin >> t;
    for (cout << fixed << setprecision(12); t--; QAQ());
}

詳細信息

answer.code: In function ‘void QAQ()’:
answer.code:91:44: error: ‘o’ was not declared in this scope
   91 |                 ans = max(ans, t + (a[j] - o) * a[i]);
      |                                            ^