QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#596710 | #9417. Palindromic Polygon | ucup-team3519# | WA | 1ms | 3868kb | C++17 | 1.7kb | 2024-09-28 16:19:20 | 2024-09-28 16:19:24 |
Judging History
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 - 1LL * 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: 3788kb
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: 3660kb
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: 3868kb
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 3824 1746 2970 1826 613 2221 1130 4677 1900 1646 564 273 3203 6572 1070 3330 1024 575 142 3038 1615 9445 2122 320 1741 2561 1145 480 1927 5119 5458 2446 3929 2249 4378 4927 2356 1473 3152 1574 1856 1609 3367 2298 1459 2663 2617 2298 4048 215 546...
result:
wrong answer 30th numbers differ - expected: '765', found: '575'