QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#102526 | #5251. Constellations | fz_zsl# | Compile Error | / | / | C++17 | 2.1kb | 2023-05-03 14:25:31 | 2023-05-03 14:25:32 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-05-03 14:25:32]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-05-03 14:25:31]
- 提交
answer
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define fi first
#define se second
const int MAX_N = 2e3 + 5;
int N, tim, T[MAX_N], sz[MAX_N];
LL X[MAX_N], Y[MAX_N], A[MAX_N], B[MAX_N], C[MAX_N];
struct node {
LL sum, sz;
pair<int, int> e;
} ;
bool operator == (const node &l, const node &r) {
return l.sum == r.sum && l.e == r.e && l.sz == r.sz;
}
bool operator < (const node &l, const node &r) {
__int128 tl = (__int128)l.sum * r.sz, (__int128)tr = r.sum * l.sz;
if (tl != tr) return tl < tr;
else {
auto u = make_pair(T[l.e.fi], T[l.e.se]);
auto v = make_pair(T[r.e.fi], T[r.e.se]);
return u > v;
}
}
int pa[MAX_N];
int getf(int x) { while (x != pa[x]) x = pa[x] = pa[pa[x]]; return x; }
void unite(int x, int y) {
x = getf(x), y = getf(y);
A[x] += A[y], B[x] += B[y], C[x] += C[y];
sz[x] += sz[y], T[x] = tim--;
pa[y] = x;
}
int main() {
scanf("%d", &N); tim = N;
for (int i = 1; i <= N; i++) {
scanf("%lld %lld", X + i, Y + i), pa[i] = i;
A[i] = X[i] * X[i] + Y[i] * Y[i];
B[i] = X[i];
C[i] = Y[i];
T[i] = tim--;
sz[i] = 1;
}
multiset<node> S;
for (int i = 1; i <= N; i++)
for (int j = i + 1; j <= N; j++)
S.insert((node){A[i] + A[j] - 2 * B[i] * B[j] - 2 * C[i] * C[j], 1, make_pair(i, j)});
for (int stp = 1; stp < N; stp++) {
auto p = *S.begin(); S.erase(S.begin());
int u = p.e.fi, v = p.e.se;
for (int i = 1; i <= N; i++) {
if (i == getf(i)) {
if (i == u || i == v) continue;
S.erase(S.find((node){A[i] + A[u] - 2 * B[i] * B[u] - 2 * C[i] * C[u], sz[i] * sz[u],
(T[i] < T[u] ? make_pair(u, i) : make_pair(i, u))}));
S.erase(S.find((node){A[i] + A[v] - 2 * B[i] * B[v] - 2 * C[i] * C[v], sz[i] * sz[v],
(T[i] < T[v] ? make_pair(v, i) : make_pair(i, v))}));
}
}
unite(u, v);
printf("%d\n", sz[getf(u)]);
for (int i = 1; i <= N; i++) {
if (i == getf(i) && i != u) {
S.insert((node){A[i] + A[u] - 2 * B[i] * B[u] - 2 * C[i] * C[u], sz[i] * sz[u],
(T[i] < T[u] ? make_pair(u, i) : make_pair(i, u))});
}
}
}
return 0;
}
详细
answer.code: In function ‘bool operator<(const node&, const node&)’: answer.code:17:48: error: expected unqualified-id before ‘__int128’ 17 | __int128 tl = (__int128)l.sum * r.sz, (__int128)tr = r.sum * l.sz; | ^~~~~~~~ answer.code:17:48: error: expected ‘)’ before ‘__int128’ 17 | __int128 tl = (__int128)l.sum * r.sz, (__int128)tr = r.sum * l.sz; | ~^~~~~~~~ | ) answer.code:18:19: error: ‘tr’ was not declared in this scope; did you mean ‘tl’? 18 | if (tl != tr) return tl < tr; | ^~ | tl answer.code: In function ‘int main()’: answer.code:34:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 34 | scanf("%d", &N); tim = N; | ~~~~~^~~~~~~~~~ answer.code:36:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 36 | scanf("%lld %lld", X + i, Y + i), pa[i] = i; | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~