QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#738811#9417. Palindromic Polygonhydrolyzed_WA 2ms7816kbC++231.4kb2024-11-12 20:01:252024-11-12 20:01:26

Judging History

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

  • [2024-11-12 20:01:26]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:7816kb
  • [2024-11-12 20:01:25]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int MxN = 550;
const ll INF = 1e18 + 100ll;

int v[MxN << 1];
pair<ll, ll> p[MxN << 1];
ll dp[MxN << 1][MxN << 1], dp2[MxN << 1][MxN << 1];

ll cross(pair<ll, ll> u, pair<ll, ll> v) {
  return u.first * v.second - v.first * u.second;
}

inline void solve() {
  int n;
  cin >> n;
  for(int i=1; i<=n; ++i) {
    cin >> v[i];
    v[i + n] = v[i];
  }
  for(int i=1; i<=n; ++i) {
    cin >> p[i].first >> p[i].second;
    p[i + n] = p[i];
  }
  for(int i=1; i<=2*n; ++i) {
    for(int j=1; j<=2*n; ++j) {
      dp[i][j] = -INF;
      dp2[i][j] = -INF;
      if(i < j && v[i] == v[j]) {
        dp2[i][j] = cross(p[i], p[j]);
      }
    }
  }
  for(int i=1; i<=n; ++i) {
    dp2[i][i] = 0ll;
  }
  ll answer = 0ll;
  for(int sz=1; sz<=n; ++sz) {
    for(int l=1; l+sz-1<=2*n; ++l) {
      int r = l + sz - 1;
      answer = max(answer, dp2[l][r] + cross(p[r], p[l]));
      for(int m=1; m<l; ++m) {
        dp[m][r] = max(dp[m][r], cross(p[m], p[l]) + dp2[l][r]);
      }
      for(int m=r+1; m<=2*n; ++m) {
        if(v[m] != v[l]) {
          continue;
        }
        dp2[l][m] = max(dp2[l][m], dp[l][r] + cross(p[r], p[m]));
      }
    }
  }
  cout << answer << "\n";
  return ;
}

signed main(int argc, char *argv[]) {
  cin.tie(nullptr)->ios::sync_with_stdio(false);
  int t;
  cin >> t;
  while(t--) {
    solve();
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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: 2ms
memory: 7816kb

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
806
877
516
2496
3559
1165
3468
560
925
3502
12
3653
1432
2970
1826
202
1682
1083
4671
1825
1646
564
273
3151
6572
1070
3122
438
765
142
3038
1615
9445
2026
320
1741
2561
1145
480
2094
5119
5214
1590
3929
2249
4378
4927
2299
1473
2944
1574
1990
1609
2402
2298
1391
2663
2617
2224
4048
141
246
13...

result:

wrong answer 2nd numbers differ - expected: '1068', found: '806'