QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#601603 | #5251. Constellations | hzy99999 | WA | 4198ms | 160428kb | C++20 | 1.7kb | 2024-09-30 08:53:04 | 2024-09-30 08:53:04 |
Judging History
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 = 1; j <= n; j++)
dist[i][j] = 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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3840kb
input:
2 0 0 1 0
output:
2
result:
ok single line: '2'
Test #2:
score: -100
Wrong Answer
time: 4198ms
memory: 160428kb
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'