QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#601156 | #5251. Constellations | hzy99999 | WA | 3567ms | 35020kb | C++20 | 2.3kb | 2024-09-29 21:09:01 | 2024-09-29 21:09:02 |
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;
// const double eps = 1e-8;
LL dist[N][N];
int n;
PII point[N];
int sz[N], year[N]; // year越小越老
// int dcmp(double a, double b)
// {
// if (fabs(a - b) < eps)
// return 0;
// if (a < b)
// return -1;
// return 1;
// }
LL get_dist(PII a, PII b)
{
int dx = a.x - b.x, dy = a.y - b.y;
// return sqrt(dx * dx + dy * dy);
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++)
sz[i] = 1;
for (int i = 1; i <= n; i++)
{
int x, y;
cin >> x >> y;
point[i] = {x, y};
year[i] = i;
}
int stand = n;
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]);
vector<int> num;
for (int i = 1; i <= n; i++)
num.push_back(i);
for (int k = 1; k < n; k++)
{
PII t = {-1, -1}; // 存位置
double minv = 1e18;
for (int i = 0; i < num.size(); i++)
for (int j = i + 1; j < num.size(); j++)
{
int a = num[i], b = num[j];
if (year[a] < year[b])
swap(a, b);
if (t.x == -1 || minv * (sz[a] + sz[b]) > dist[a][b] * (sz[num[t.x]] + sz[num[t.y]]) || minv * (sz[a] + sz[b]) == dist[a][b] * (sz[num[t.x]] + sz[num[t.y]]) && (year[num[t.x]] > year[a] || year[num[t.x]] == year[a] && year[num[t.y]] < year[b]))
t = {i, j}, minv = dist[a][b];
}
for (int i = 0; i < num.size(); i++)
{
if (i == t.x || i == t.y)
continue;
int x = num[t.x], y = num[t.y];
int a = num[i];
dist[x][a] = dist[a][x] = (dist[x][a] * sz[x] + dist[y][a] * sz[y]); // / (sz[x] + sz[y]);
}
sz[num[t.x]] += sz[num[t.y]], sz[num[t.y]] = 0;
year[num[t.x]] = ++stand;
cout << sz[num[t.x]] << endl;
num.erase(num.begin() + t.y);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3672kb
input:
2 0 0 1 0
output:
2
result:
ok single line: '2'
Test #2:
score: -100
Wrong Answer
time: 3567ms
memory: 35020kb
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 1963rd lines differ - expected: '64', found: '128'