QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#89355 | #5251. Constellations | molarsu | WA | 6220ms | 151220kb | C++20 | 1.6kb | 2023-03-19 20:39:08 | 2023-03-19 20:39:11 |
Judging History
answer
#include<bits/stdc++.h>
#define ri register int
#define fu(i, a, b) for(ri i = (a), ed = (b); i <= ed; ++i)
#define fd(i, a, b) for(ri i = (a), ed = (b); i >= ed; --i)
using namespace std;
#define int long long
const int N = 5e3 + 5;
const double eps = 1e-6;
const int INF = 0x3f3f3f3f3f3f3f3f;
int read() {
int f = 1, x = 0; char ch = getchar();
while (ch > '9' || ch < '0') { if (ch == '-')f = -1; ch = getchar(); }
while (ch <= '9' && ch >= '0') { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); }
return x * f;
}
long double dis[N][N];
struct Node {
int x, y, rk, sz;
}a[N];
bool vis[N];
signed main() {
int n = read();
vector<int> vec;
fu(i, 1, n) a[i].x = read(), a[i].y = read(), a[i].rk = i, a[i].sz = 1, vec.push_back(i);
fu(i, 1, n) fu(j, 1, n) dis[i][j] = (a[i].x - a[j].x) * (a[i].x - a[j].x) + (a[i].y - a[j].y) * (a[i].y - a[j].y);
int tot = n;
fd(_, n - 1, 1) {
int x = 0, y = 0;
long double mi = INF;
fu(i, 0, signed(vec.size()) - 1) {
int u = a[vec[i]].rk;
fu(j, i + 1, signed(vec.size()) - 1) {
int v = a[vec[j]].rk;
if (1.0 * dis[u][v] / a[u].sz / a[v].sz - mi < eps) x = i, y = j, mi = dis[u][v] / a[u].sz / a[v].sz;
}
}
//cout << x << ' ' << y << endl;
tot++;
int u = vec[x], v = vec[y];
a[tot].sz = a[u].sz + a[v].sz;
a[tot].rk = tot;
vec.erase(vec.begin() + y);
vec.erase(vec.begin() + x);
fu(i, 0, signed(vec.size()) - 1) {
int now = a[vec[i]].rk;
dis[now][tot] = dis[tot][now] = dis[now][u] + dis[now][v];
}
vec.push_back(tot);
printf("%lld\n", a[tot].sz);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3584kb
input:
2 0 0 1 0
output:
2
result:
ok single line: '2'
Test #2:
score: -100
Wrong Answer
time: 6220ms
memory: 151220kb
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 1969th lines differ - expected: '80', found: '96'