QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#89350 | #5251. Constellations | molarsu | WA | 8457ms | 199512kb | C++20 | 1.6kb | 2023-03-19 20:35:48 | 2023-03-19 20:35:50 |
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-3;
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;
}
int 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);
memset(dis, 0x3f, sizeof dis);
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 = -1, y = -1;
int mi = INF;
fu(i, 0, signed (vec.size()) - 1) {
int u = vec[i];
fu(j, i + 1, signed (vec.size()) - 1) {
int v = vec[j];
if(x == -1 && y == -1)x = i, y = j, mi = dis[u][v];
else if (dis[u][v] * a[vec[x]].sz * a[vec[y]].sz < mi * a[u].sz * a[v].sz) x = i, y = j, mi = dis[u][v];
}
}
//cout << x << ' ' << y << endl;
tot++;
int u = vec[x], v = vec[y];
a[tot].sz = a[u].sz + a[v].sz;
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: 32ms
memory: 199240kb
input:
2 0 0 1 0
output:
2
result:
ok single line: '2'
Test #2:
score: -100
Wrong Answer
time: 8457ms
memory: 199512kb
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 1753rd lines differ - expected: '16', found: '32'