QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#622625#9417. Palindromic PolygonLegend_dy#WA 1ms3700kbC++201.8kb2024-10-08 23:23:572024-10-08 23:23:58

Judging History

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

  • [2024-10-08 23:23:58]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3700kb
  • [2024-10-08 23:23:57]
  • 提交

answer

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define dbg(x) cout<<#x"="<<x<<' '

using namespace std;
typedef long long ll;

const int N = 500 + 5;
int n, f[N * 2];
ll dp[N * 2][N * 2], ans;
struct Point {
    ll x, y;
};
Point p[N * 2];

Point operator-(Point u, Point v) {
    return Point({u.x - v.x, u.y - v.y});
}

ll operator*(Point u, Point v) {
    return u.y * v.x - u.x * v.y;
}

ll dfs(int l, int r) {
    if(dp[l][r] != -1) return dp[l][r];
    dp[l][r] = 0;
    unordered_map<int, int> mp1, mp2;
    for(int i = r - 1; i > l; i--) {
        mp1[f[i]] = i;
    }
    for(int i = l + 1; i < r; i++) {
        mp2[f[i]] = i;
    }
    for(auto [v, nl] : mp1) {
        int nr = mp2[v];
        if(nl == nr) {
            dp[l][r] = max(dp[l][r], dfs(nl, nr) + abs((p[l] - p[nl]) * (p[r] - p[nr])));
        } else {
            dp[l][r] = max(dp[l][r], dfs(nl, nr) + abs((p[nl] - p[l]) * (p[nr] - p[l])) + abs((p[l] - p[r]) * (p[nr] - p[r])));
        }
    }
    ans = max(ans, dp[l][r]);
    return dp[l][r];
}

void solve() {
    cin >> n;

    ans = 0;
    for(int i = 1; i <= n; i++) {
        dp[i][i] = 0;
        for(int j = i + 1; j <= n + n; j++)
            dp[i][j] = -1;
    }

    for(int i = 1; i <= n; i++) {
        cin >> f[i];
        f[i + n] = f[i];
    }
    for(int i = 1; i <= n; i++) {
        cin >> p[i].x >> p[i].y;
        p[i + n] = p[i];
    }
    for(int i = 1; i <= n; i++) {
        for(int j = i + n - 1; j > i; j--) {
            if(f[i] == f[j])
                dfs(i, j);
        }
    }
    cout << ans << endl;
}

int main() {
    fastio;
    int T = 1;
    cin >> T;
    while(T--) {
        solve();
    }
    return 0;
}

详细

Test #1:

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

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

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

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
3653
1746
2970
1826
613
2221
1590
4677
1900
1646
564
273
3287
6572
1070
3122
1024
575
142
3038
1615
9445
2026
320
1741
2561
1145
480
1927
5119
5458
2446
3929
2249
4378
4927
2299
1473
2944
1574
1856
1609
2725
2088
1448
2663
2617
2298
4048
215
546...

result:

wrong answer 13th numbers differ - expected: '3824', found: '3653'