QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#89348 | #5251. Constellations | FUCKUCUP | WA | 7839ms | 285188kb | C++14 | 3.0kb | 2023-03-19 20:31:35 | 2023-03-19 20:31:37 |
Judging History
answer
#include <bits/stdc++.h>
#define fp(i, a, b) for(int i = (a), ed = (b); i <= ed; ++i)
#define fb(i, a, b) for(int i = (a), ed = (b); i >= ed; --i)
#define go(u, i) for(int i = head[u]; i; i = e[i].nxt)
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
inline int rd() {
register int x(0), f(1); register char c(getchar());
while (c < '0' || '9' < c) { if (c == '-')f = -1; c = getchar(); }
while ('0' <= c && c <= '9')x = x*10 + c-'0', c = getchar();
return x*f;
}
inline LL RD() {
register LL x(0); register int f(1); register char c(getchar());
while (c < '0' || '9' < c) { if (c == '-')f = -1; c = getchar(); }
while ('0' <= c && c <= '9')x = x*10 + c-'0', c = getchar();
return x*f;
}
inline int int_rand(int l, int r){
int res = 1.0l*rand()/RAND_MAX*(r-l+1);
if(res == r-l+1)res = r-l;
return l+res;
}
inline LL LL_rand(LL l, LL r){
LL res = 1.0l*rand()/RAND_MAX*(r-l+1);
if(res == r-l+1)res = r-l;
return l+res;
}
const int maxn = 2010;
const double eps = 1e-3;
int n, x[maxn], y[maxn], vis[maxn];
struct pdi{
double dist;
int p;
};
struct node{
set<pdi> st;
int id, siz;
double d[maxn];
}a[maxn];
inline bool operator < (const pdi &x, const pdi &y){
if(fabs(x.dist-y.dist) >= eps)return x.dist < y.dist;
return a[x.p].id < a[y.p].id;
}
inline int dist(int p, int q){
return (x[p]-x[q])*(x[p]-x[q]) + (y[p]-y[q])*(y[p]-y[q]);
}
int main(){
// freopen("a.in", "r", stdin);
// freopen("a.out", "w", stdout);
n = rd();
fp(i, 1, n)x[i] = rd(), y[i] = rd(), a[i].id = i, a[i].siz = 1;
fp(i, 1, n){
fp(j, 1, n)if(i != j){
a[i].d[j] = dist(i, j);
a[i].st.insert((pdi){a[i].d[j], j});
}
}
fp(t, 2, n){
pii now = make_pair(0, 0); double dist = 1e18;
fp(i, 1, n)if(!vis[i]){
// printf("%d: ", a[i].id);
// for(auto &x : a[i].st)printf("%lf ", x.dist); puts("");
if(dist-a[i].st.begin()->dist >= eps){
int p = a[i].st.begin()->p, q = i;
if(a[p].id < a[q].id)swap(p, q);
now = make_pair(p, q), dist = a[i].st.begin()->dist;
}else if(fabs(dist-a[i].st.begin()->dist) < eps){
int p = a[i].st.begin()->p, q = i;
if(a[p].id < a[q].id)swap(p, q);
if(a[p].id < a[now.first].id)now = make_pair(p, q);
else if(a[p].id == a[now.first].id && a[q].id < a[now.second].id)now = make_pair(p, q);
}
}
int p = now.first, q = now.second;
fp(i, 1, n)if(!vis[i] && i != p && i != q){
double dist1 = a[i].d[p], dist2 = a[i].d[q];
a[i].st.erase((pdi){a[i].d[p], p}), a[p].st.erase((pdi){a[p].d[i], i});
a[i].st.erase((pdi){a[i].d[q], q}), a[q].st.erase((pdi){a[q].d[i], i});
dist1 *= a[i].siz*a[p].siz, dist2 *= a[i].siz*a[q].siz;
a[i].d[p] = a[p].d[i] = (dist1+dist2)/a[i].siz/(a[p].siz+a[q].siz);
}
// printf("%d %d\n", a[p].id, a[q].id);
vis[q] = 1, a[p].siz += a[q].siz, a[p].id = n+t-1, a[p].st.erase((pdi){a[p].d[q], q});
fp(i, 1, n)if(!vis[i] && i != p && i != q){
a[i].st.insert((pdi){a[i].d[p], p}), a[p].st.insert((pdi){a[p].d[i], i});
}
printf("%d\n", a[p].siz);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 11612kb
input:
2 0 0 1 0
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 3750ms
memory: 284996kb
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:
ok 1999 lines
Test #3:
score: 0
Accepted
time: 3628ms
memory: 285176kb
input:
2000 -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 -971...
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:
ok 1999 lines
Test #4:
score: 0
Accepted
time: 3615ms
memory: 285000kb
input:
2000 -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 -10...
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:
ok 1999 lines
Test #5:
score: 0
Accepted
time: 3688ms
memory: 284996kb
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 -9...
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:
ok 1999 lines
Test #6:
score: 0
Accepted
time: 3954ms
memory: 284972kb
input:
2000 1000 -250 1000 -249 1000 -248 1000 -247 1000 -246 1000 -245 1000 -244 1000 -243 1000 -242 1000 -241 1000 -240 1000 -239 1000 -238 1000 -237 1000 -236 1000 -235 1000 -234 1000 -233 1000 -232 1000 -231 1000 -230 1000 -229 1000 -228 1000 -227 1000 -226 1000 -225 1000 -224 1000 -223 1000 -222 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:
ok 1999 lines
Test #7:
score: 0
Accepted
time: 3557ms
memory: 285036kb
input:
2000 0 -1000 0 -999 0 -998 0 -997 0 -996 0 -995 0 -994 0 -993 0 -992 0 -991 0 -990 0 -989 0 -988 0 -987 0 -986 0 -985 0 -984 0 -983 0 -982 0 -981 0 -980 0 -979 0 -978 0 -977 0 -976 0 -975 0 -974 0 -973 0 -972 0 -971 0 -970 0 -969 0 -968 0 -967 0 -966 0 -965 0 -964 0 -963 0 -962 0 -961 0 -960 0 -959 ...
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:
ok 1999 lines
Test #8:
score: -100
Wrong Answer
time: 7839ms
memory: 285188kb
input:
2000 -400 571 -725 636 -880 529 -657 372 -383 382 -746 888 -604 785 -497 557 -677 977 -562 917 -530 623 -636 535 -816 579 -633 428 -573 561 -496 479 -409 448 -570 379 -421 795 -827 865 -730 809 -423 984 -676 772 -398 816 -451 373 -756 777 -351 829 -954 345 -543 871 -595 521 -501 734 -378 769 -987 60...
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 3 2 2 2 2 2 2 2 2 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 2 2 2 2 2 2 2 2 2 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 2 2 2 2 2 2 2 2 2 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 2 ...
result:
wrong answer 227th lines differ - expected: '3', found: '2'