QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#598850#9417. Palindromic Polygonucup-team3924#WA 0ms3592kbC++202.0kb2024-09-28 23:41:002024-09-28 23:41:03

Judging History

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

  • [2024-09-28 23:41:03]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3592kb
  • [2024-09-28 23:41:00]
  • 提交

answer

#include <bits/stdc++.h>

struct Point {
    int x, y;
};

long long det(Point a, Point b, Point c) {
    return (long long)a.x * b.y +
           (long long)b.x * c.y +
           (long long)c.x * a.y -
           (long long)a.x * c.y -
           (long long)b.x * a.y -
           (long long)c.x * b.y;
}

void solve_test() {
    int n;
    std::cin >> n;

    std::vector<int> f(n);

    for (int i = 0; i < n; i++)
        std::cin >> f[i];

    std::vector<Point> p(n);

    for (int i = 0; i < n; i++)
        std::cin >> p[i].x >> p[i].y;

    std::vector<std::vector<long long>> dp(n, std::vector<long long>(n, (1LL << 63)));
    std::vector<std::vector<int>> paired(n, std::vector<int>(n));

    std::cerr << (1LL << 63) << "\n";

    for (int i = 0; i < n; i++) {
        dp[i][i] = 0;
        paired[i][i] = i;

        int ii = (i + 1) % n;
        if (f[i] == f[ii]) {
            dp[i][ii] = 0;
            paired[i][ii] = i;
        }
    }

    long long res = 0LL;

    for (int len = 3; len <= n; len++) {
        for (int i = 0; i < n; i++) {
            int j = (i + len - 1) % n;

            int ii = (i + 1) % n;
            int jj = (j - 1 + n) % n;

            if (f[i] == f[j]) {
                for (int dk = 1; dk < len - 1; dk++) {
                    int k = (i + dk) % n;

                    long long new_area = dp[ii][k];
                    int pp = paired[ii][k];
                    
                    new_area += std::abs(det(p[i], p[pp], p[k])) + std::abs(det(p[i], p[k], p[j]));

                    if (new_area > dp[i][j]) {
                        dp[i][j] = new_area;
                        paired[i][j] = i;
                    }
                }
            }

            if (dp[ii][j] > dp[i][j]) {
                dp[i][j] = dp[ii][j];
                paired[i][j] = paired[ii][j];
            }
        
            if (dp[i][j] > res)
                res = dp[i][j];
        }
    }

    std::cout << res << "\n";
}

int main() {
    int t;
    std::cin >> t;

    while (t--) solve_test();

    return 0;
}


详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3572kb

input:

3
8
2 4 2 4 3 4 5 3
2 3
0 6
-3 3
-3 0
-2 -3
1 -5
3 -3
4 0
3
1 2 3
0 0
1 0
0 1
3
1 1 1
0 0
1 0
0 1

output:

84
0
1

result:

ok 3 number(s): "84 0 1"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3576kb

input:

1
4
1000000000 1000000000 1000000000 1000000000
-1000000000 -1000000000
1000000000 -1000000000
1000000000 1000000000
-1000000000 1000000000

output:

8000000000000000000

result:

ok 1 number(s): "8000000000000000000"

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3592kb

input:

129
10
604040473 604040473 287094217 682965575 70435786 287094217 604040473 287094217 682965575 92620053
-193 -184
-200 -200
-125 -169
-120 -157
-120 -145
-124 -139
-137 -136
-155 -149
-172 -163
-187 -177
5
346787871 346787871 113397429 113397429 346787871
-173 -181
-186 -166
-200 -195
-194 -200
-17...

output:

3573
1068
877
402
2496
3559
1165
3373
390
925
3502
606
3824
1508
2970
1586
202
1996
1130
4671
1900
1646
489
273
3203
6572
1070
3258
438
575
142
3038
1615
9445
2076
220
1741
2561
1145
480
2094
5119
5214
1846
3929
2073
4378
4927
2356
1473
2944
1574
1990
1609
3136
2298
1459
2276
2617
2224
3774
215
344
...

result:

wrong answer 1st numbers differ - expected: '3857', found: '3573'