QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#611941 | #9417. Palindromic Polygon | shiqiaqiaya# | WA | 1ms | 3908kb | C++17 | 3.8kb | 2024-10-05 00:32:21 | 2024-10-05 00:32:23 |
Judging History
answer
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define int long long
using i64 = long long;
using i128 = __int128;
mt19937_64 rd(time(0));
template <class K, class C = less<>> using paring_heap = __gnu_pbds::priority_queue<K, C>;
template <class K> using rb_tree = tree<K, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T, class ... A> void debug(const T & t, const A & ... a) { cerr << "[" << t, ((cerr << ", " << a), ...), cerr << "]\n"; }
const i64 mod = [](bool n) { return n ? 998244353 : 1e9 + 7; } (1);
const double pi = acos(-1);
struct point : array<int, 2> { // int 遇到奇怪问题可重载各种比较符号
int operator * (const point & t) { return at(0) * t[1] - at(1) * t[0]; } // 叉积
int operator / (const point & t) { return at(0) * t[0] + at(1) * t[1]; } // 内积
point & operator += (const point & t) { return at(0) += t[0], at(1) += t[1], *this; }
point operator + (const point & t) { return point(*this) += t; }
point & operator -= (const point & t) { return at(0) -= t[0], at(1) -= t[1], *this; }
point operator - (const point & t) { return point(*this) -= t; }
point & operator *= (const int & t) { return at(0) *= t, at(1) *= t, *this; }
point operator * (const int & t) { return point(*this) *= t; }
point & operator /= (const int & t) { return at(0) /= t, at(1) /= t, *this; }
point operator / (const int & t) { return point(*this) /= t; }
};
void QAQ() {
int n;
cin >> n;
vector<point> a(2 * n);
vector<int> c(n);
for (auto & x : c) {
cin >> x;
}
c.resize(2 * n);
for (int i = 0; i < n; i++) {
cin >> a[i][0] >> a[i][1];
c[i + n] = c[i];
a[i + n] = a[i];
}
// point o = {(int)2e9, (int)2e9};
point o = {0, 0};
// point o = {45, 45};
vector dp(2 * n, vector<array<int, 3>>(2 * n, {-1, -1, -1}));
auto vis = dp;
auto dfs = [&](auto && self, int l, int r, int op) -> int {
if (l > r || vis[l][r][op] != -1) return dp[l][r][op];
vis[l][r][op] = 0;
if (l == r) return dp[l][r][op] = op == 2 ? 0 : -1;
if (op == 2) {
dp[l][r][op] = (a[l] - o) * (a[r] - o);
for (int i = l + 1; i < r; i++) {
auto t1 = self(self, i, r, 0), t2 = self(self, l, i, 1);
if (t1 != -1) {
dp[l][r][op] = max(dp[l][r][op], (a[l] - o) * (a[i] - o) + t1);
} if (t2 != -1) {
dp[l][r][op] = max(dp[l][r][op], (a[i] - o) * (a[r] - o) + t2);
}
}
} else if (op == 0) {
for (int i = l; i < r; i++) if (c[l] == c[i]) {
auto t = self(self, l, i, 2);
if (t != -1) {
dp[l][r][op] = max(dp[l][r][op], (a[i] - o) * (a[r] - o) + t);
}
}
} else {
for (int i = l + 1; i <= r; i++) if (c[i] == c[r]) {
auto t = self(self, i, r, 2);
if (t != -1) {
dp[l][r][op] = max(dp[l][r][op], (a[l] - o) * (a[i] - o) + t);
}
}
}
return dp[l][r][op];
};
int ans = 0;
for (int i = 0; i < 2 * n; i++) {
for (int j = i; j < 2 * n && (j - i + 1) <= n; j++) if (c[i] == c[j]) {
auto t = dfs(dfs, i, j, 2);
if (t != -1) {
ans = max(ans, t + (a[j] - o) * (a[i] - o));
}
}
}
cout << ans << "\n";
}
signed main() {
cin.tie(0) -> sync_with_stdio(0);
int t = 1;
cin >> t;
for (cout << fixed << setprecision(12); t--; QAQ());
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3908kb
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: 3692kb
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: 3864kb
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 2668 3559 1165 3468 560 925 3502 696 3824 1746 2970 1647 613 2221 1130 4671 1900 1602 564 273 3151 6419 849 3330 473 541 142 3038 1615 9445 2122 320 1634 2561 1145 480 1089 5119 5458 2446 3929 2249 4102 4927 2356 1452 2944 1574 1480 1578 3367 1892 1459 2663 2617 2298 3763 215 546 18...
result:
wrong answer 2nd numbers differ - expected: '1068', found: '806'