QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#618159#9417. Palindromic Polygonsupepapupu#WA 1ms3884kbC++201.8kb2024-10-06 19:20:462024-10-06 19:20:46

Judging History

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

  • [2024-10-06 19:20:46]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3884kb
  • [2024-10-06 19:20:46]
  • 提交

answer

#include <bits/stdc++.h>

#define x first
#define y second
#define el '\n'
#define debug(x) cerr << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int N = 3e5 + 10, mod = 998244353;
const ll INF = 4e18;

pll operator-(const pll &a, const pll &b) {
    return {a.x - b.x, a.y - b.y};
}
ll operator^(const pll &a, const pll &b) {
    return a.x * b.y - a.y * b.x;
}
ll area(const pll &a, const pll &b, const pll &c) {
    return abs((b - a) ^ (c - a));
}
__int128 sq(ll x) {
    return (__int128)x * x;
}

void solve() {
    int n; cin >> n;
    vector<int> s(n);
    vector<pll> q(n);
    for (int i = 0; i < n; ++i) cin >> s[i], s.emplace_back(s[i]);
    for (int i = 0; i < n; ++i) {
        cin >> q[i].x >> q[i].y;
        q.emplace_back(q[i]);
    }
    vector<vector<int>> match(n * 2, vector<int>(n * 2));
    for (int i = 0; i < n * 2; ++i) {
        match[i][i] = i;
        for (int j = i + 1; j < n * 2; ++j) {
            match[i][j] = match[i][j - 1];
            if (s[i] == s[j]) match[i][j] = j;
        }
    }
    vector<vector<ll>> f(n * 2, vector<ll>(n * 2));
    ll ans = 0;
    for (int len = 1; len < n; ++len) {
        for (int i = 0; i + len < n * 2; ++i) {
            int j = i + len;
            if (s[i] != s[j]) continue;
            for (int k = i + 1; k < j; ++k) {
                f[i][j] = max(f[i][j], area(q[i], q[j], q[match[k][j - 1]]) + area(q[k], q[match[k][j - 1]], q[i]) + f[k][match[k][j - 1]]);
            }
            ans = max(ans, f[i][j]);
        }
    }
    cout << ans << el;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int tcase = 1;
    cin >> tcase;
    while (tcase--) solve();
}

详细

Test #1:

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

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: 3616kb

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: 1ms
memory: 3884kb

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:

3857
1068
877
516
2668
3559
1165
3468
560
925
3502
696
3824
1746
2970
1826
613
2221
1130
4677
1900
1646
564
273
3203
6572
1070
3330
1024
765
142
3038
1615
9445
2122
320
1741
2561
1145
480
2094
5119
5458
2446
3929
2249
4378
4927
2299
1473
2944
1574
1990
1609
3367
2088
1459
2663
2617
2298
4048
215
546...

result:

wrong answer 49th numbers differ - expected: '2356', found: '2299'