QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#618148#9417. Palindromic Polygonsupepapupu#WA 1ms3600kbC++201.8kb2024-10-06 19:11:412024-10-06 19:11:42

Judging History

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

  • [2024-10-06 19:11:42]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3600kb
  • [2024-10-06 19:11:41]
  • 提交

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<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[k]));
            }
            int x = i + 1, y = j - 1;
            while (x <= y) {
                if (s[x] != s[y]) --y;
                else {
                    f[i][j] = max(f[i][j], f[x][y] + area(q[i], q[j], q[y]) + area(q[x], q[y], q[i]));
                    ++x, --y;
                }
            }
            // cerr << i << ' ' >> j << el;
            // debug(f[i][j]);
            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();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3524kb

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

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

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
2108
2543
1165
3240
560
555
2914
696
3653
1432
2970
1826
613
2221
1083
4586
1798
1646
564
273
3029
6400
849
3330
1024
575
142
2720
1615
9445
2002
320
1634
2561
1145
375
1927
5119
5458
1590
3929
1671
4378
4927
2245
1473
2944
1548
1856
1609
2725
2088
1008
2663
2617
2041
4030
215
546
...

result:

wrong answer 5th numbers differ - expected: '2668', found: '2108'