QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#610636 | #9417. Palindromic Polygon | treasuresgc | WA | 1ms | 3656kb | C++23 | 1.9kb | 2024-10-04 16:45:31 | 2024-10-04 16:45:32 |
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=1e9;
inline void solve()
{
mp.clear();
int n;
n=read();
for(int i=1;i<=n;i++) f[i]=read();
// reverse(f+1,f+n+1);
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;
// reverse(x+1,x+n+1);
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));
}
int sum=0;
for(int i=1;i<=n;i++)
{
sum=0;
for(int j=i;j<=i+n-1;j++) sum=sum+cvec(j,j+1);
// cout<<sum<<endl;
// system("pause");
}
cout<<ans<<endl;
}
signed main()
{
int T;
T=read();
while(T--) solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3656kb
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: 3656kb
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: 3616kb
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 29999994700 3559 1165 107999982234 560 925 125999980223 696 63999992805 1746 2970 67999988157 613 101999982568 21999996826 137999976448 1900 1646 564 273 27999998299 141999979403 1070 29999996586 1024 765 142 81999986786 79999987161 9445 3999999488 320 91999985061 11999998512 1145 ...
result:
wrong answer 5th numbers differ - expected: '2668', found: '29999994700'