QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#100651 | #5373. 投影对称 | zhouhuanyi | 20 | 29ms | 3684kb | C++11 | 2.0kb | 2023-04-27 15:05:04 | 2023-04-27 15:05:16 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<cmath>
#include<set>
#include<algorithm>
#define N 2000
#define eps 1e-9
#define inf 1e9
using namespace std;
int read()
{
char c=0;
int sum=0,f=1;
while (c!='-'&&(c<'0'||c>'9')) c=getchar();
if (c=='-') c=getchar(),f=-1;
while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
return sum*f;
}
struct reads
{
int x,y;
};
reads st[N+1],tong[N+1];
double get(double a,double b)
{
if (abs(a)<eps) return -inf;
return b/a;
}
struct rds
{
double a,b;
bool operator < (const rds &t)const
{
return get(a,b)<get(t.a,t.b);
}
};
set<rds>s;
int n,length;
bool used[N+1];
double sx,sy,delta[N+1];
int main()
{
bool op;
double a,b,ds;
n=read();
for (int i=1;i<=n;++i) st[i].x=read(),st[i].y=read(),sx+=st[i].x,sy+=st[i].y;
sx/=n,sy/=n;
for (int i=1;i<=n;++i)
if (!used[i])
{
if (abs(st[i].x-sx)<eps&&abs(st[i].y-sy)<eps)
{
used[i]=1;
break;
}
for (int j=i+1;j<=n;++j)
if (!used[j]&&abs(st[i].x+st[j].x-sx*2)<eps&&abs(st[i].y+st[j].y-sy*2)<eps)
{
used[i]=used[j]=1;
break;
}
}
for (int i=1;i<=n;++i)
if (!used[i])
tong[++length]=st[i];
if (!length)
{
puts("-1");
return 0;
}
for (int i=2;i<=length;++i)
{
a=tong[1].x+tong[i].x-sx*2,b=tong[1].y+tong[i].y-sy*2;
for (int j=1;j<=length;++j) delta[j]=tong[j].x*b-tong[j].y*a;
ds=sx*b-sy*a,sort(delta+1,delta+length+1),op=1;
for (int j=1;j<=length;++j) op&=(abs(delta[j]+delta[length+1-j]-ds*2)<eps);
if (op) s.insert((rds){b,-a});
}
for (int i=3;i<=length;++i)
{
a=tong[2].x+tong[i].x-sx*2,b=tong[2].y+tong[i].y-sy*2;
for (int j=1;j<=length;++j) delta[j]=tong[j].x*b-tong[j].y*a;
ds=sx*b-sy*a,sort(delta+1,delta+length+1),op=1;
for (int j=1;j<=length;++j) op&=(abs(delta[j]+delta[length+1-j]-ds*2)<eps);
if (op) s.insert((rds){b,-a});
}
printf("%d\n",s.size());
return 0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3504kb
input:
3 32650 -45713 899736 648739 381340 196264
output:
0
result:
wrong answer 1st lines differ - expected: '3', found: '0'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 20
Accepted
Test #13:
score: 20
Accepted
time: 2ms
memory: 3684kb
input:
1986 -130037 -139562 -244707 -368070 -124449 -171906 -121655 -188078 27969 61170 148227 257334 -54541 -130426 183181 278074 97877 102650 218135 298814 0 -999131 0 999131 0 -997957 0 997957 0 -997214 0 997214 0 -993580 0 993580 0 -992530 0 992530 0 -989565 0 989565 0 -989244 0 989244 0 -988703 0 9887...
output:
5
result:
ok single line: '5'
Test #14:
score: 0
Accepted
time: 29ms
memory: 3444kb
input:
1946 143587 172352 65745 94316 -12097 16280 -221429 -250388 89939 61756 -65745 -94316 0 -9966 0 9966 0 -9961 0 9961 0 -9955 0 9955 0 -9917 0 9917 0 -9866 0 9866 0 -9828 0 9828 0 -9823 0 9823 0 -9819 0 9819 0 -9804 0 9804 0 -9785 0 9785 0 -9727 0 9727 0 -9702 0 9702 0 -9668 0 9668 0 -9653 0 9653 0 -9...
output:
2
result:
ok single line: '2'
Subtask #4:
score: 0
Skipped
Dependency #1:
0%