QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#618152#9417. Palindromic Polygonsupepapupu#WA 1ms3596kbC++202.1kb2024-10-06 19:13:522024-10-06 19:13:53

Judging History

This is the latest submission verdict.

  • [2024-10-06 19:13:53]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3596kb
  • [2024-10-06 19:13:52]
  • Submitted

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;
                }
            }
            x = i + 1, y = j - 1;
            while (x <= y) {
                if (s[x] != s[y]) ++x;
                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: 0ms
memory: 3596kb

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

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
2668
3559
1165
3333
560
555
2914
696
3824
1746
2970
1826
613
2221
1130
4671
1867
1646
564
273
3203
6572
1070
3330
1024
575
142
2720
1615
9445
2122
320
1741
2561
1145
375
1927
5119
5458
2446
3929
1684
4378
4927
2299
1473
2944
1574
1856
1609
3367
2088
1076
2663
2617
2298
4048
215
546...

result:

wrong answer 8th numbers differ - expected: '3468', found: '3333'