QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#610646 | #9417. Palindromic Polygon | treasuresgc | WA | 1ms | 3692kb | C++23 | 1.7kb | 2024-10-04 16:49:09 | 2024-10-04 16:49:09 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read()
{
int sum=0,f=1;
char ch=getchar();
while(!isdigit(ch)){if(ch=='-')f*=-1;ch=getchar();}
while(isdigit(ch)){sum=sum*10+ch-48;ch=getchar();}
return sum*f;
}
int f[1005];
int dp[1005][1005];
int x[1005],y[1005];
vector<int> V[505];
map<int,int> mp;
inline int cvec(int a,int b)
{
return (y[a]+y[b])*(x[a]-x[b]);
}
inline void calc(int L,int R,int l,int r)
{
// cout<<L<<" "<<R<<" "<<l<<" "<<r<<endl;
// cout<<dp[L][R]<<" "<<dp[l][r]<<" "<<cvec(L,l)<<" "<<cvec(r,R)<<endl;
// cout<<dp[l][r]+cvec(L,l)+cvec(r,R)<<endl;
// system("pause");
dp[L][R]=max(dp[L][R],dp[l][r]+cvec(L,l)+cvec(r,R));
}
const int Ng=0;
inline void solve()
{
mp.clear();
int n;
n=read();
for(int i=1;i<=n;i++) f[i]=read();
int cnt=0;
for(int i=1;i<=n;i++)
{
if(mp.count(f[i])) f[i]=mp[f[i]];
else
{
mp[f[i]]=++cnt;
f[i]=cnt;
}
}
for(int i=1;i<=n;i++) x[i]=read(),x[i]+=Ng,y[i]=read(),y[i]+=Ng;
for(int i=n+1;i<=n*2;i++) f[i]=f[i-n],x[i]=x[i-n],y[i]=y[i-n];
int ans=0;
for(int len=1;len<=n;len++)
for(int l=1;l<=n;l++)
{
int r=l+len-1;
if(f[l]!=f[r]) continue;
dp[l][r]=cvec(l,r);
for(int k=l+1;k<r;k++)V[f[k]].push_back(k);
for(int g=1;g<=cnt;g++)
{
if(V[g].size()==0) continue;
for(int j=0;j<V[g].size();j++) calc(l,r,V[g][0],V[g][j]);
for(int j=1;j<V[g].size();j++) calc(l,r,V[g][j],V[g].back());
}
for(int g=1;g<=cnt;g++) V[g].clear();
// cout<<l<<" "<<r<<" "<<dp[l][r]<<" "<<cvec(r,l)<<" "<<dp[l][r]+cvec(r,l)<<endl;
ans=max(ans,dp[l][r]+cvec(r,l));
}
cout<<ans<<endl;
}
signed main()
{
int T;
T=read();
while(T--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3600kb
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: 1ms
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: 3660kb
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:
5857 5317 877 516 15128 6838 2041 3468 560 4165 3502 696 3653 1746 11541 1826 613 1682 2428 4677 3306 9110 564 273 16557 9287 1070 7886 1024 765 142 7469 1615 13575 2385 320 1741 8051 1145 480 2094 5119 23038 1590 13150 2249 6070 18289 4065 1473 9980 1574 1990 8339 19289 2298 4645 2663 2617 13534 40...
result:
wrong answer 1st numbers differ - expected: '3857', found: '5857'