QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#610067#9417. Palindromic PolygonKomorebie#WA 1ms5756kbC++172.7kb2024-10-04 14:51:152024-10-04 14:51:16

Judging History

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

  • [2024-10-04 14:51:16]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5756kb
  • [2024-10-04 14:51:15]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define maxn 3004
ll t, n, minn = 0;
long double maxx = 0;
int last[maxn][maxn], nex[maxn][maxn];
long double ans;
unordered_map<ll, int> f;
int tot = 0;
struct point {
    ll x, y, f;
} a[maxn];

ll mul(point a, point b) { return a.x * b.y - a.y * b.x; }

void dfs(int v, int u, long double ans)
{
    int min1 = 0, max1 = INT_MAX;

    if (u == v) {
        maxx = max(abs(ans), maxx);
        return;
    }

    else if (u == v + 1) {
        return;
    }

    for (int i = v + 1; i < u; i++) {
        if (true) {
            min1 = max(last[u][a[i].f], min1);
            dfs(i, last[u][a[i].f], ans + mul(a[v], a[i]) + mul(a[last[u][a[i].f]], a[u]));
        }
    }

    for (int i = u - 1; i >= v + 1; i--) {
        if (true) {
            max1 = min(nex[v][a[i].f], max1);
            if (i != last[u][a[i].f])  // 上面的一层搜索已经搜过了
                dfs(i, nex[v][a[i].f], ans + mul(a[v], a[nex[v][a[i].f]]) + mul(a[i], a[u]));
        }
    }

    return;
}
void solve(int x)
{
    int v = x + 1, u;
    ll maxi = 0;
    for (int i = n + x; i >= x + 3 && i >= minn; i--) {
        if (a[i].f == a[v].f) {
            maxi = max((ll)i, maxi);
            dfs(v, i, mul(a[i], a[v]));
        }
    }
    minn = max(minn, maxi);
    return;
}
int main()
{
    ios::sync_with_stdio(false);
    cin >> t;
    while (t--) {
        cin >> n;
        for (int i = 1; i <= n; i++) {
            cin >> a[i].f;
            a[i + n].f = a[i].f;
            if (!f[a[i].f]) {
                f[a[i].f] = ++tot;
            }
        }

        for (int i = 1; i <= n; i++) {
            cin >> a[i].x >> a[i].y;
            a[i + n].x = a[i].x;
            a[i + n].y = a[i].y;
            int x = f[a[i].f];
            a[i].f = a[i + n].f = x;
        }

        memset(last[1], 0, sizeof(last[1]));

        memset(nex[2 * n - 1], 0, sizeof(nex[2 * n - 1]));

        for (int i = 2; i < 2 * n; i++) {
            for (int j = 1; j <= tot; j++) {
                if (a[i - 1].f == j)
                    last[i][j] = i - 1;
                else
                    last[i][j] = last[i - 1][j];
            }
        }

        for (int i = 2 * n - 2; i >= 1; i--) {
            for (int j = 1; j <= tot; j++) {
                if (a[i + 1].f == j)
                    nex[i][j] = i + 1;
                else
                    nex[i][j] = nex[i + 1][j];
            }
        }

        for (int i = 0; i < n; i++) {
            solve(i);
        }

        cout << (ll)(maxx + 0.5) << endl;
        maxx = 0;
        minn = 0;
        tot = 0;
        f.clear();
    }
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 5756kb

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: 1ms
memory: 5708kb

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'