QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#625285#9417. Palindromic PolygonOoWA 0ms3820kbC++202.6kb2024-10-09 18:24:342024-10-09 18:24:35

Judging History

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

  • [2024-10-09 18:24:35]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3820kb
  • [2024-10-09 18:24:34]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1010;
struct point {
    int x, y;
    int c;
    point() {}
    point(int _x, int _y) : x(_x), y(_y), c{} {}
    point operator-(const point &k) const { return point(x - k.x, y - k.y); }
} a[N];
int cross(point k1, point k2) { return abs(k1.x * k2.y - k1.y * k2.x); }
int calc(point a1, point a2, point b1, point b2) {
    return cross(b1 - a1, b2 - a1) + cross(b2 - a1, a2 - a1);
}
int calc(point a1, point a2, point b) { return cross(a1 - b, a2 - b); }
void solve() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i].c;
    for (int i = 1; i <= n; i++) cin >> a[i].x >> a[i].y;
//    vector<int> v;
//    for (int i = 1; i <= n; i++) v.push_back(a[i].c);
//    sort(v.begin(), v.end());
//    v.erase(unique(v.begin(), v.end()), v.end());
//    for (int i = 1; i <= n; i++) a[i].c = lower_bound(v.begin(), v.end(), a[i].c) - v.begin();
    for (int i = 1; i <= n; i++) a[i + n] = a[i];
    vector<vector<int>> dp(n * 2 + 1, vector<int>(n * 2 + 1));
    for (int len = 1; len <= n; len++)
        for (int l = 1; l <= n; l++) {
            int r = l + len - 1;
            if (a[l].c != a[r].c) continue;
//            vector<int> col;
//            vector<vector<int>> pos(v.size() + 1);
            for (int k = l + 1; k < r; k++) {
                int c = a[k].c;
//                if (pos[c].size() == 0) col.push_back(c);
//                pos[c].push_back(k);
                dp[l][r] = max(dp[l][r], calc(a[l], a[r], a[k]));
            }
            for(int i = l + 1; i < r; i++)
            	for(int j = i + 1; j < r; j++) {
            		if(a[i].c != a[j].c) continue;
            		dp[l][r] = max(dp[l][r], dp[i][j] + calc(a[l], a[r], a[i], a[j]));
				}
//            for (auto c : col) {
//                if (pos[c].size() == 1) continue;
//                for (int i = 1; i < pos[c].size(); i++)
//                    dp[l][r] = max(dp[l][r], dp[pos[c].front()][pos[c][i]] +
//                                                 calc(a[l], a[r], a[pos[c].front()], a[pos[c][i]]));
//                for (int i = 0; i < pos[c].size() - 1; i++)
//                    dp[l][r] = max(dp[l][r], dp[pos[c][i]][pos[c].back()] +
//                                                 calc(a[l], a[r], a[pos[c][i]], a[pos[c].back()]));
//            }
	
        }
    int ans = 0;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= 2 * n; j++) ans = max(ans, dp[i][j]);
    cout << ans << '\n';
}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int T;
    cin >> T;
    while (T--) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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: 0ms
memory: 3820kb

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
2496
3559
1165
3468
560
925
3502
696
3653
1746
2970
1826
613
1682
1083
4677
1900
1646
564
273
3151
6572
1070
3122
1024
765
142
3038
1615
9445
2026
320
1741
2561
1145
480
2094
5119
5458
1590
3929
2249
4378
4927
2356
1473
3152
1574
1990
1609
2402
2298
1391
2663
2617
2298
4048
215
546...

result:

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