QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#622729#9417. Palindromic PolygonLegend_dyWA 1ms3688kbC++202.5kb2024-10-09 01:07:332024-10-09 01:07:34

Judging History

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

  • [2024-10-09 01:07:34]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3688kb
  • [2024-10-09 01:07:33]
  • 提交

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];

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

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

int lf[N], rf[N];
ll dfs(int l, int r) {
    if(dp[l][r] != -1) return dp[l][r];
    ll dplr = 0;
    for(int i = l + 1; i < r; i++) {
        rf[f[i]] = i;
    }
    for (int i = r - 1; i > l; i--) {
        lf[f[i]] = i;
    }
    for (int i = l + 1; i < r; i++) {
        int nl = i, nr = rf[f[i]];
        if(i != rf[f[i]])
            dplr = max(dplr, dfs(nl, nr) + std::abs((p[nl] - p[l]) * (p[nr] - p[l])) + std::abs((p[l] - p[r]) * (p[nr] - p[r])));
        nl = lf[f[i]], nr = i;
        if(i != lf[f[i]])
            dplr = max(dplr, dfs(nl, nr) + std::abs((p[nl] - p[l]) * (p[nr] - p[l])) + std::abs((p[l] - p[r]) * (p[nr] - p[r])));
                
        dplr = max(dplr, std::abs((p[l] - p[i]) * (p[r] - p[i])));
        // if(nl == nr) {
        //     dp[l][r] = max(dp[l][r], std::abs((p[l] - p[nl]) * (p[r] - p[nr])));
        // } else {
        //     dp[l][r] = max(dp[l][r], dfs(nl, nr) + std::abs((p[nl] - p[l]) * (p[nr] - p[l])) + std::abs((p[l] - p[r]) * (p[nr] - p[r])));
        // }
    }
    dp[l][r] = dplr;
    ans = max(ans, dp[l][r]);
    return dp[l][r];
}

void solve() {
    cin >> n;

    ans = 0;
    for(int i = 1; i <= n + n; i++) {
        dp[i][i] = 0;
        for(int j = i + 1; j <= n + n; j++)
            dp[i][j] = -1;
    }
    vector<int> vec;
    for(int i = 1; i <= n; i++) {
        cin >> f[i];
        vec.push_back(f[i]);
        f[i + n] = f[i];
    }
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    for(int i = 1; i <= n + n; i++) {
        f[i] = lower_bound(vec.begin(), vec.end(), f[i]) - vec.begin();
    }

    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 << '\n';
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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

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
3813
560
925
3502
696
3824
1746
3364
1826
613
2221
1276
4677
2869
1646
564
273
3203
6572
1070
3330
1024
868
142
3189
1615
9445
2122
320
1741
2561
1145
480
2094
5119
5458
2446
3929
2249
4378
4927
2429
1473
2944
1574
1990
1609
3367
2088
1459
2663
2745
2298
4455
215
546...

result:

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