QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#596684#9417. Palindromic Polygonucup-team3519#WA 0ms3824kbC++171.7kb2024-09-28 16:16:262024-09-28 16:16:32

Judging History

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

  • [2024-09-28 16:16:32]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3824kb
  • [2024-09-28 16:16:26]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define V vector
#define fi first
#define se second
#define pb push_back
#define lb lower_bound
#define all0(x) (x).begin(), (x).end()
#define all1(x) (x).begin() + 1, (x).end()
typedef pair<int, int> pi;
typedef long long LL;

LL det(pi a, pi b) {
    return 1LL * a.fi * b.se - a.se * b.fi;
}

void solve() {
    int n; cin >> n;
    V<int> f(n * 2);
    V<int> uni(1);
    for(int i = 0; i < n; i++) cin >> f[i], f[i + n] = f[i], uni.pb(f[i]);
    sort(all1(uni));
    uni.erase(unique(all1(uni)), uni.end());
    for(int i = 0; i < 2 * n; i++) f[i] = lb(all1(uni), f[i]) - uni.begin();

    V<pi> a(n * 2);
    for(int i = 0; i < n; i++) {
        cin >> a[i].fi >> a[i].se;
        a[i + n] = a[i];
    }
    auto cal = [&](pi a, pi b, pi c, pi d) {
        return det(a, c) + det(c, d) + det(d, b) + det(b, a);
    };
    LL ans = 0;
    V<V<LL>> dp(n * 2, V<LL>(n * 2));
    V<int> ocur(n + 1, -1);
    for(int len = 1; len <= n; len++) {
        for(int l = 0; l < 2 * n - len + 1; l++) {
            int r = l + len - 1;
            if(f[l] != f[r]) continue;
            for(int i = l + 1; i < r; i++) {
                if(ocur[f[i]] == -1) {
                    ocur[f[i]] = i;
                }
            }

            for(int i = l + 1; i < r; i++) {
                dp[l][r] = max(dp[l][r], dp[ocur[f[i]]][i] + cal(a[l], a[r], a[ocur[f[i]]], a[i]));
            }

            for(int i = l + 1; i < r; i++) {
                ocur[f[i]] = -1;
            }
            ans = max(ans, dp[l][r]);
        }
    }
    cout << ans << endl;
}

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

详细

Test #1:

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

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: -100
Wrong Answer
time: 0ms
memory: 3664kb

input:

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

output:

4000000000000000000

result:

wrong answer 1st numbers differ - expected: '8000000000000000000', found: '4000000000000000000'