QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#609318#9417. Palindromic Polygonlllei#WA 0ms3672kbC++201.7kb2024-10-04 12:02:492024-10-04 12:02:50

Judging History

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

  • [2024-10-04 12:02:50]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3672kb
  • [2024-10-04 12:02:49]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=550;
int n;
struct Nnode{
    int f;
    long long x,y;

}a[N*2];
long long trisize(Nnode t1,Nnode t2,Nnode t3)//triangle
{
    long long xx1=t1.x-t2.x,yy1=t1.y-t2.y;
    long long xx2=t3.x-t2.x,yy2=t3.y-t2.y;
    return abs(xx1*yy2-xx2*yy1);
}
long long dp[N*2][N*2][2];
const long long inf=1e18;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    int T;
    cin>>T;
while(T--){    
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i].f;
    for(int i=1;i<=n;i++) cin>>a[i].x>>a[i].y;
    for(int i=n+1;i<=n*2;i++) a[i]=a[i-n];
    for(int l=1;l<=2*n;l++)
        for(int r=l+1;r<=2*n;r++)
        {
            dp[l][r][1]=-inf;
            if(l>n||r>=l+n){
                dp[l][r][0]=-inf;
                continue;
            }
            if(a[l].f==a[r].f) dp[l][r][0]=0;
            else dp[l][r][0]=-inf;
        }
    for(int l=1;l<=n;l++)
        for(int r=l+n-1;r>l;r--)
        if(a[l].f==a[r].f){
            for(int rr=l+1;rr<r;rr++)
                dp[l][rr][1]=max(dp[l][rr][1],dp[l][r][0]+trisize(a[l],a[rr],a[r]));
        }
        else{
            for(int ll=l+1;ll<r;ll++)
                if(a[ll].f==a[r].f)
                {
                    dp[ll][r][0]=max(dp[ll][r][0],dp[l][r][1]+trisize(a[l],a[ll],a[r]));
                }
        }
    long long ans=0;
    for(int l=1;l<=n;l++)
        for(int r=l+1;r<l+n;r++)
        {
            ans=max(ans,dp[l][r][0]);
            for(int mid=l+1;mid<r;mid++)
                ans=max(ans,dp[l][r][0]+trisize(a[l],a[mid],a[r]));
        }
    cout<<ans<<'\n';
}
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: -100
Wrong Answer
time: 0ms
memory: 3672kb

input:

1
4
1000000000 1000000000 1000000000 1000000000
-1000000000 -1000000000
1000000000 -1000000000
1000000000 1000000000
-1000000000 1000000000

output:

4000000000000000000

result:

wrong answer 1st numbers differ - expected: '8000000000000000000', found: '4000000000000000000'