QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#601613#5251. Constellationshzy99999WA 2616ms149556kbC++201.7kb2024-09-30 09:08:222024-09-30 09:08:24

Judging History

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

  • [2024-09-30 09:08:24]
  • 评测
  • 测评结果:WA
  • 用时:2616ms
  • 内存:149556kb
  • [2024-09-30 09:08:22]
  • 提交

answer

#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#define x first
#define y second
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int N = 2e3 + 10, M = N * N;
int n, idx;
bool st[N * 2];
int sz[N * 2];
PII point[N];
LL dist[2 * N][2 * N];
typedef struct Node
{
    int u, v;
    bool operator<(const Node &t) const
    {
        LL res1 = dist[u][v] * sz[t.u] * sz[t.v];
        LL res2 = dist[t.u][t.v] * sz[u] * sz[v];
        if (res1 != res2)
            return res1 < res2;
        return u != t.u ? u < t.u : v < t.v;
    }
} Node;
LL get_dist(PII a, PII b)
{
    int dx = a.x - b.x, dy = a.y - b.y;
    return dx * dx + dy * dy;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        int x, y;
        cin >> x >> y;
        point[i] = {x, y};
        sz[i] = 1;
    }
    idx = n;
    priority_queue<Node> heap;
    for (int i = 1; i <= n; i++)
        for (int j = i + 1; j <= n; j++)
            dist[i][j] = dist[j][i] = get_dist(point[i], point[j]), heap.push({i, j});
    while (heap.size())
    {
        Node t = heap.top();
        heap.pop();
        if (st[t.u] || st[t.v])
            continue;
        st[t.u] = 1, st[t.v] = 1;
        int x = ++idx;
        sz[x] = sz[t.u] + sz[t.v];
        for (int i = 1; i < idx; i++)
        {
            if (st[i])
                continue;
            dist[x][i] = dist[i][x] = dist[t.u][i] + dist[t.v][i];
            heap.push({i, x});
        }
        cout << sz[x] << endl;
    }
    return 0;
}

详细

Test #1:

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

input:

2
0 0
1 0

output:

2

result:

ok single line: '2'

Test #2:

score: -100
Wrong Answer
time: 2616ms
memory: 149556kb

input:

2000
1000 -1000
1000 -999
1000 -998
1000 -997
1000 -996
1000 -995
1000 -994
1000 -993
1000 -992
1000 -991
1000 -990
1000 -989
1000 -988
1000 -987
1000 -986
1000 -985
1000 -984
1000 -983
1000 -982
1000 -981
1000 -980
1000 -979
1000 -978
1000 -977
1000 -976
1000 -975
1000 -974
1000 -973
1000 -972
1000...

output:

2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

wrong answer 295th lines differ - expected: '2', found: '4'