QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#99924 | #5251. Constellations | cardinal_city# | WA | 1756ms | 102144kb | C++20 | 1.7kb | 2023-04-24 03:54:52 | 2023-04-24 03:54:54 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct Clln {
int ind;
ll sqr, sumx, sumy;
int sz;
bool operator< (const Clln &o) const {
return ind < o.ind;
}
pair<ll, ll> dist_to(const Clln &o) {
return {sqr + o.sqr - 2*sumx*o.sumx - 2*sumy*o.sumy, sz * o.sz};
}
};
struct Dist {
pair<ll, ll> d; int ai, bi;
bool operator< (const Dist &o) const {
return d.first * o.d.second > o.d.first * d.second;
}
};
int main() {
int n; cin >> n;
vector<Clln> cllns(2*n+1, { -1, 0, 0, 0, 0 });
priority_queue<Dist> dsts;
vector<bool> used(2*n+1);
for (int i = 0; i < n; i++) {
ll x, y; cin >> x >> y;
Clln c = { i, (x*x + y*y), x, y, 1 };
cllns[i] = c;
for (Clln &o : cllns) {
if (o.ind == -1 || o.ind == i) continue;
Dist dd = { c.dist_to(o), o.ind, i };
dsts.push(dd);
}
}
int ci = n;
while (!dsts.empty()) {
Dist cd = dsts.top(); dsts.pop();
if (used[cd.ai] || used[cd.bi]) continue;
cout << (cllns[cd.ai].sz + cllns[cd.bi].sz) << '\n';
Clln nc = {
ci,
cllns[cd.ai].sqr + cllns[cd.bi].sqr,
cllns[cd.ai].sumx + cllns[cd.bi].sumx,
cllns[cd.ai].sumy + cllns[cd.bi].sumy,
cllns[cd.ai].sz + cllns[cd.bi].sz,
};
cllns[ci] = nc;
ci++;
used[cd.ai] = used[cd.bi] = 1;
for (Clln &o : cllns) {
if (o.ind == -1 || o.ind == nc.ind || used[o.ind]) continue;
Dist dd = { nc.dist_to(o), o.ind, nc.ind };
dsts.push(dd);
}
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 3400kb
input:
2 0 0 1 0
output:
2
result:
ok single line: '2'
Test #2:
score: -100
Wrong Answer
time: 1756ms
memory: 102144kb
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 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 10...
result:
wrong answer 2nd lines differ - expected: '2', found: '3'