QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#670216#9417. Palindromic Polygon1025497292WA 0ms3516kbC++172.2kb2024-10-23 20:52:192024-10-23 20:52:21

Judging History

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

  • [2024-10-23 20:52:21]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3516kb
  • [2024-10-23 20:52:19]
  • 提交

answer

#include<bits/stdc++.h>
#define endl '\n'
#define int long long
#define double long double
#define Vector Point
#define Mirai ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
typedef pair<int,int> pii;
const double eps=1e-12;
struct Point
{
    int x,y;
    Point(int x=0,int y=0):x(x),y(y){};
    Vector operator-(const Vector &o)const{return Vector(x-o.x,y-o.y);}
};
int Cross(Vector a,Vector b){return abs(a.x*b.y-a.y*b.x);}
void show(Point a){cout<<a.x<<" "<<a.y<<endl;}
void solve()
{
    int n;cin>>n;
    vector<int> val(n*2+1);
    vector<Point> p(n*2+1);
    for(int i=1;i<=n;i++)
    {
        cin>>val[i];
        val[i+n]=val[i];
    }
    for(int i=1;i<=n;i++)
    {
        cin>>p[i].x>>p[i].y;
        p[i+n]=p[i];
    }
    vector<vector<int>> dp(n*2+1,vector<int>(n*2+1,-1e18));
    vector<pii> maxl(n*2+1,{0,0});
    for(int i=1;i<=2*n;i++)
    {
        dp[i][i]=0;
        maxl[i].second=i;
    }
    int res=0;
    for(int len=2;len<=n-1;len++)
    {
        for(int l=1;l<=n;l++)
        {
            int r=l+len;
            // cout<<l<<" "<<r<<" "<<val[l ]<<" "<<val[r]<<endl;
            if(val[l]!=val[r])continue;
            for(int l1=l+1;l1<r;l1++)
            {
                int r1=maxl[l1].second;
                if(r1>=r)continue;
                if(l1!=r1)dp[l][r]=max(dp[l][r],maxl[l1].first+Cross(p[l1]-p[r],p[r1]-p[r])+Cross(p[l1]-p[l],p[l1]-p[r]));
                else dp[l][r]=max(dp[l][r],maxl[l1].first+Cross(p[l]-p[l1],p[r]-p[l1]));
                // if(l==4&&len==6)
                // {
                //     cout<<r1<<" "<<dp[l][r]<<endl;
                //     cout<<Cross(p[l]-p[l1],p[r]-p[l1])<<endl;
                //     show(p[l]-p[l1]);
                //     show(p[r]-p[l1]);
                // }
                if(dp[l][r]>maxl[l].first)
                {
                    maxl[l].first=dp[l][r];
                    maxl[l].second=r;
                }
            }
            res=max(res,dp[l][r]);
            // cout<<l<<" "<<r<<" "<<res<<endl;
        }
    }
    cout<<res<<endl;
}
signed main()
{
    Mirai;
    int T=1;
    cin>>T;
    while(T--)
    {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 3516kb

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'