QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#89352 | #5251. Constellations | molarsu | WA | 4807ms | 87728kb | C++20 | 1.6kb | 2023-03-19 20:37:17 | 2023-03-19 20:37:19 |
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;
}
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;
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;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3508kb
input:
2 0 0 1 0
output:
2
result:
ok single line: '2'
Test #2:
score: -100
Wrong Answer
time: 4807ms
memory: 87728kb
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'