QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#102688 | #5251. Constellations | csw_ccc# | WA | 6357ms | 15724kb | C++14 | 2.7kb | 2023-05-03 16:05:05 | 2023-05-03 16:05:07 |
Judging History
answer
#include <iostream>
#include <cstring>
#include <map>
#include <cstdio>
#include <queue>
#include <algorithm>
#define ll long long
using namespace std;
struct point
{
ll yy, xx;
ll x, y;
int num;
void show()
{
printf("yy:%lld y:%lld; xx:%lld x:%lld. num:%d\n",yy,y,xx,x,num);
}
};
struct line
{
int a, b;
double dis;
line(int _a, int _b, double _dis)
{
a = _a;
b = _b;
dis = _dis;
}
};
const int maxn = 3000+5;
int n;
int cnt;
point poi[maxn*maxn];
template<class T>
inline void read(T &x);
void init()
{
read(n);
for (int i = 1; i <= n; i++)
{
read (poi[i].x); read(poi[i].y);
poi[i].xx = poi[i].x * poi[i].x;
poi[i].yy = poi[i].y * poi[i].y;
poi[i].num = 1;
}
}
int head, tail;
int q[maxn * maxn];
bool used[maxn*maxn];
inline double getDis(int i, int j)
{
double dy = (double)poi[i].yy * poi[j].num + (double)poi[j].yy * poi[i].num - 2 * poi[i].y * poi[j].y;
double dx = (double)poi[i].xx * poi[j].num + (double)poi[j].xx * poi[i].num - 2 * poi[i].x * poi[j].x;
return (dy + dx) / (poi[i].num * poi[j].num);
}
inline bool com(const line &l1, const line &l2)
{
if (abs(l1.dis - l2.dis) > 1e-8)
return l1.dis < l2.dis;
if (max(l1.a, l1.b) != max(l2.a, l2.b))
return max(l1.a, l1.b) < max(l2.a, l2.b);
return min(l1.a, l1.b) < min(l2.a, l2.b);
}
void work()
{
for (int i = 1; i <= n; i++) q[i] = i;
head = 1; tail = n;
while (head != tail)
{
line Min_line(q[head], q[head+1], getDis(q[head], q[head+1]));
for (int i = head; i <= tail; i++)
for (int j = i + 1; j <= tail; j++)
{
line now(q[i], q[j], getDis(q[i],q[j]));
if (!com(Min_line, now)) Min_line = now;
}
int pre_tail = tail;
for (; head <= pre_tail; head++)
{
if (q[head] == Min_line.a || q[head] == Min_line.b) continue;
q[++tail] = q[head];
}
// cout << Min_line.a << ' ' << Min_line.b << endl;
cnt++;
poi[cnt].num = poi[Min_line.a].num + poi[Min_line.b].num;
poi[cnt].yy = poi[Min_line.a].yy + poi[Min_line.b].yy;
poi[cnt].y = poi[Min_line.a].y + poi[Min_line.b].y;
poi[cnt].x = poi[Min_line.a].x + poi[Min_line.b].x;
poi[cnt].xx = poi[Min_line.a].xx + poi[Min_line.b].xx;
// poi[cnt].show();
q[++tail] = cnt;
cout << poi[cnt].num << endl;
}
}
void print()
{
}
int main()
{
// freopen("test.in","r",stdin);
// freopen("test.out","w",stdout);
init();
work();
print();
return 0;
}
template<class T>
inline void read(T &x)
{
x = 0; T s = 1;
char c = getchar();
while(c < '0' || c > '9') {if(c == '-') s = -1; c = getchar();}
while(c >= '0' && c <= '9') {x = x*10+c-'0'; c = getchar();}
x *= s;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 7424kb
input:
2 0 0 1 0
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 6332ms
memory: 15560kb
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: 6338ms
memory: 13748kb
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: 6357ms
memory: 15560kb
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: 6310ms
memory: 13504kb
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: 6305ms
memory: 13640kb
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: 6306ms
memory: 15724kb
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: 4628ms
memory: 13508kb
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 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 98304 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 131072 2 4 8 16 32 64 128 256 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 147456 2 4 8 16 32 64 128 25...
result:
wrong answer 2nd lines differ - expected: '2', found: '4'