QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#610446#9417. Palindromic PolygonUESTC_Snow_Halation#WA 1ms9920kbC++143.7kb2024-10-04 15:59:282024-10-04 15:59:32

Judging History

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

  • [2024-10-04 15:59:32]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:9920kb
  • [2024-10-04 15:59:28]
  • 提交

answer

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#define FOR() ll le=e[u].size();for(ll i=0;i<le;i++)
#define QWQ cout<<"QwQ\n";
#define ll long long
#include <vector>
#include <queue>
#include <map>

using namespace std;
const ll N=555;
const ll qwq=303030;
const ll inf=0x3f3f3f3f;

inline ll read() {
    ll sum = 0, ff = 1; char c = getchar();
    while(c<'0' || c>'9') { if(c=='-') ff = -1; c = getchar(); }
    while(c>='0'&&c<='9') { sum = sum * 10 + c - '0'; c = getchar(); }
    return sum * ff;
}

ll T;
ll n;
ll a[N],c[N];
struct E{
    ll x,y;
}b[N];
ll vis[N][N];
ll f[N][N];
ll f2[N][N];
// ll mi[N][N][N];
map <ll,ll> fi;
ll ans = 0;
int sum[N][N];

inline E operator - (E A,E B) { return {A.x-B.x,A.y-B.y}; }
inline ll cha(E A,E B) { return abs(A.x*B.y-A.y*B.x); }

inline ll ask(ll i,ll j,ll k) {
    return cha(b[i]-b[j],b[i]-b[k]);
}

inline ll ask2(ll i,ll j,ll k,ll l) {
    return ask(i,j,k)+ask(k,l,j);
}

int head[N]={}, cur[N]={}, you[N]={};

void DFS(ll i,ll j) {
    memset(head,0,sizeof(int) * (n+5));
    memset(cur,0,sizeof(int) * (n+5));
    memset(you,0,sizeof(int) * (n+5));

    for(ll k=(i+1)%n;k!=j;(k+=1)%=n) {
        f[i][j] = max(f[i][j],ask(i,j,k));
        int c = a[k];
        if(!you[c]) {
            head[c] = k;
        }
        you[c]++;
        cur[c] = k;
    }

    for(ll y=(i+1)%n;y!=j;(y+=1)%=n) {
        int c = a[y];
        ll x = head[c];
        if(you[c]==2) continue;
        if(x==y) continue;
    // cout<<"i = "<<i<<" j = "<<j<<" : ";
        // cout<<" x = "<<x<<" y = "<<y<<"\n";
        f[i][j] = max(f[i][j],ask2(i,j,x,y)+f[x][y]);
        f2[i][j] = max(f2[i][j],ask2(i,j,x,y)+f2[x][y]);
    }
    for(ll x=(i+1)%n;x!=j;(x+=1)%=n) {
        int c = a[x];
        ll y = cur[c];
        if(x==y) continue;

    // cout<<"i = "<<i<<" j = "<<j<<" : ";
        // cout<<" x = "<<x<<" y = "<<y<<"\n";
        f[i][j] = max(f[i][j],ask2(i,j,x,y)+f[x][y]);
        f2[i][j] = max(f2[i][j],ask2(i,j,x,y)+f2[x][y]);
    }
}

void chushihua() {
    fi.clear();
    ans = 0;
    for(ll i=0;i<=n;i++) for(ll j=0;j<=n;j++) vis[i][j] = f[i][j] = f2[i][j] = 0;
}

int main() {
    // freopen("data.in","r",stdin);
    T = read();
    while(T--) {
        chushihua();
        n = read();
        for(ll i=0;i<n;i++) {
            a[i] = read(); c[i] = a[i];
        }
        sort(c,c+n);
        ll now = 0;
        for(ll i=0;i<n;i++) {
            if(i==0 || c[i]!=c[i-1]) now++;
            fi[c[i]] = now;
        }
        for(ll i=0;i<n;i++) a[i] = fi[a[i]];

        // sum[0][a[0]] = 1;
        // for(int i=1;i<n;i++) {
        //     sum[i][a[i]] = 1;
        //     for(int j=1;j<=n;j++) sum[i][j] += sum[i-1][j];
        // }

        for(ll i=0;i<n;i++) {
            b[i].x = read(); b[i].y = read();
        }
        for(ll i=1;i<n;i++) {
            for(ll j=0;j<n;j++) {
                if(a[(i+i)%n]!=a[j]) continue;
                DFS(j,(j+i)%n);
            }
        }
        // for(ll i=0;i<n;i++) {
        //     for(ll j=0;j<n;j++) {
        //         if(a[i]!=a[j] || i==j) continue;
        //         DFS(i,j);
        //     }
        // }
        for(ll i=0;i<n;i++) {
            for(ll j=(i+1)%n;j<n;j++) {
                if(a[i]!=a[j]) continue;
                ans = max(ans, f2[i][j] + f2[j][i]);
                ans = max(ans, f[i][j] + f2[j][i]);
                ans = max(ans, f2[i][j] + f[j][i]);
            }
        }
        cout<<ans<<"\n";
    }
    return 0;
}

/*

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


*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 9920kb

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:

0
0
1

result:

wrong answer 1st numbers differ - expected: '84', found: '0'