QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#599352#9417. Palindromic Polygonucup-team3099#Compile Error//C++143.8kb2024-09-29 03:41:062024-09-29 03:41:06

Judging History

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

  • [2024-09-29 03:41:06]
  • 评测
  • [2024-09-29 03:41:06]
  • 提交

answer

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

template <class T> int sgn(T x) { return (x > 0) - (x < 0); }
template<class T>
struct Point {
    typedef Point P;
    T x, y;
    explicit Point(T x=0, T y=0) : x(x), y(y) {}
    bool operator<(P p) const { return tie(x,y) < tie(p.x,p.y); }
    bool operator==(P p) const { return tie(x,y)==tie(p.x,p.y); }
    P operator+(P p) const { return P(x+p.x, y+p.y); }
    P operator-(P p) const { return P(x-p.x, y-p.y); }
    P operator*(T d) const { return P(x*d, y*d); }
    P operator/(T d) const { return P(x/d, y/d); }
    T dot(P p) const { return x*p.x + y*p.y; }
    T cross(P p) const { return x*p.y - y*p.x; }
    T cross(P a, P b) const { return (a-*this).cross(b-*this); }
    T dist2() const { return x*x + y*y; }
    double dist() const { return sqrt((double)dist2()); }
    // angle to x-axis in interval [-pi, pi]
    double angle() const { return atan2(y, x); }
    P unit() const { return *this/dist(); } // makes dist()=1
    P perp() const { return P(-y, x); } // rotates +90 degrees
    P normal() const { return perp().unit(); }
    // returns point rotated 'a' radians ccw around the origin
    P rotate(double a) const {
        return P(x*cos(a)-y*sin(a),x*sin(a)+y*cos(a)); }
    friend ostream& operator<<(ostream& os, P p) {
        return os << "(" << p.x << "," << p.y << ")"; }
};

using P = Point<int64_t>;

const int64_t INF = 4E18;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t; cin >> t;
    while (t--) {
        int n; cin >> n;
        vector<int> f(n);
        for (int i = 0; i < n; i++) {
            cin >> f[i];
        }
        vector<P> pts(n);
        for (int i = 0; i < n; i++) {
            cin >> pts[i].x >> pts[i].y;
        }
        vector dp(n, vector(n + 1, vector<int64_t>(2, -INF)));
        for (int i = 0; i < n; i++) {
            for (int len = 1; len <= n; len++) {
                int j = (i + len) % n;
                if (f[i] == f[j]) {
                    dp[i][len][0] = 0;
                }
            }
        }
        auto area = [](P a, P b, P c) {
            return abs(a.cross(b) + b.cross(c) + c.cross(a));
        };
        int64_t ans = 0;
        for (int len = 0; len <= n; len++) {
            for (int i = 0; i < n; i++) {
                for (int typ = 0; typ < 2; typ++) {
                    if (dp[i][len][typ] < 0) {
                        continue;
                    }
                    // cerr << i << " " << len << " " << typ << ": " << dp[i][len][typ] << '\n';
                    if (typ == 0) {
                        assert(f[i] == f[(i + len) % n]);
                        ans = max(ans, dp[i][len][0]);
                    }
                    int j = (i + len) % n;
                    for (int nxt = 1; nxt + len <= n; nxt++) {
                        if (typ == 0) {
                            int ni = (i - nxt + n) % n;
                            // cerr << " -> " << ni << " " << len + nxt << " " << 1 << ": " << dp[i][len][0] + area(pts[i], pts[j], pts[ni]) << '\n';
                            dp[ni][len + nxt][1] = max(dp[ni][len + nxt][1], dp[i][len][0] + area(pts[i], pts[j], pts[ni]));
                        } else {
                            int nj = (j + nxt) % n;
                            if (f[i] == f[nj]) {
                                // cerr << " -> " << i << " " << len + nxt << " " << 0 << ": " << dp[i][len][1] + area(pts[i], pts[j], pts[nj]) << '\n';
                                dp[i][len + nxt][0] = max(dp[i][len + nxt][0], dp[i][len][1] + area(pts[i], pts[j], pts[nj]));
                            }
                        }
                    }
                }
            }
        }
        cout << ans << '\n';
    }
}

Details

answer.code: In function ‘int main()’:
answer.code:51:16: error: missing template arguments before ‘dp’
   51 |         vector dp(n, vector(n + 1, vector<int64_t>(2, -INF)));
      |                ^~
answer.code:56:21: error: ‘dp’ was not declared in this scope
   56 |                     dp[i][len][0] = 0;
      |                     ^~
answer.code:67:25: error: ‘dp’ was not declared in this scope
   67 |                     if (dp[i][len][typ] < 0) {
      |                         ^~
answer.code:73:40: error: ‘dp’ was not declared in this scope
   73 |                         ans = max(ans, dp[i][len][0]);
      |                                        ^~
answer.code:80:29: error: ‘dp’ was not declared in this scope
   80 |                             dp[ni][len + nxt][1] = max(dp[ni][len + nxt][1], dp[i][len][0] + area(pts[i], pts[j], pts[ni]));
      |                             ^~
answer.code:85:33: error: ‘dp’ was not declared in this scope
   85 |                                 dp[i][len + nxt][0] = max(dp[i][len + nxt][0], dp[i][len][1] + area(pts[i], pts[j], pts[nj]));
      |                                 ^~