QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#670439#9417. Palindromic Polygon1025497292WA 1ms3776kbC++172.2kb2024-10-23 21:43:302024-10-23 21:43:30

Judging History

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

  • [2024-10-23 21:43:30]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3776kb
  • [2024-10-23 21:43:30]
  • 提交

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>> L(n*2+1,vector<int>(n*2+1));
    vector<vector<int>> R(n*2+1,vector<int>(n*2+1));
    
    for(int i=1;i<=n*2;i++)
    {
        int pos=i;
        for(int j=i;j<=n*2;j++)
        {
            if(val[i]==val[j])pos=j;
            L[i][j]=pos;
        }
    }

    for(int j=n*2;j>=1;j--)
    {
        int pos=j;
        for(int i=j;i>=1;i--)
        {
            if(val[i]==val[j])pos=i;
            R[i][j]=pos;
        }
    }

    vector<vector<int>> dp(n*2+1,vector<int>(n*2+1,0));
    int res=0;
    for(int len=2;len<=n-1;len++)
    {
        for(int l=1;l<=n;l++)
        {
            int r=l+len;
            if(val[l]!=val[r])continue;
            for(int l1=l+1;l1<r;l1++)
            {
                int r1=L[l1][r-1];
                dp[l][r]=max(dp[l][r],dp[l1][r1]+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],dp[l1][r1]+Cross(p[l]-p[l1],p[r]-p[l1]));
            }
            for(int r1=r-1;r1>l;r1--)
            {
                int l1=R[l+1][r1];
                dp[l][r]=max(dp[l][r],dp[l1][r1]+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],dp[l1][r1]+Cross(p[l]-p[l1],p[r]-p[l1]));
            }
            res=max(res,dp[l][r]);
        }
    }
    cout<<res<<endl;
}
signed main()
{
    Mirai;
    int T=1;
    cin>>T;
    while(T--)
    {
        solve();
    }
    return 0;
}

详细

Test #1:

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

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

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

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
2496
3559
1165
3468
560
925
3502
696
3653
1746
2970
1826
613
1682
1083
4677
1900
1646
564
273
3151
6572
1070
3122
1024
765
142
3038
1615
9445
2026
320
1741
2561
1145
480
2094
5119
5458
1590
3929
2249
4378
4927
2356
1473
3152
1574
1990
1609
2402
2298
1391
2663
2617
2298
4048
215
546...

result:

wrong answer 5th numbers differ - expected: '2668', found: '2496'