QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#817958#9869. Horizon ScanningxinlengweishangWA 31ms4420kbC++202.0kb2024-12-17 15:12:312024-12-17 15:12:31

Judging History

你现在查看的是最新测评结果

  • [2024-12-17 15:12:31]
  • 评测
  • 测评结果:WA
  • 用时:31ms
  • 内存:4420kb
  • [2024-12-17 15:12:31]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define ld double
using namespace std;
struct node{
	ld x,y;
}t[1000010];
ld cal(node a,node b,node c,node d){
	ld dx1=a.x-b.x,dy1=a.y-b.y;
	ld dx2=c.x-d.x,dy2=c.y-d.y;
	return dx1*dy2-dx2*dy1;
}
bool cmp1(node a,node b){
	node c;
	c.x=0;
	c.y=0;
	ld num=cal(a,c,b,c);
	if(num==0){
		if(a.x>0) return a.x<b.x;
		else return a.x>b.x; 
	}
	else if(num>0) return 1;
	else return 0;
}
vector<node> st1,st2;
vector<node> st;
ld ccal(node a,node b){
//		printf(" x1=%lld y1=%lld x2=%lld y2=%lld \n",a.x,a.y,b.x,b.y);
	node c;
	c.x=0;
	c.y=0;
	ld len=cal(a,c,b,c);
	if(len==0){
		if(a.x!=0){
			if(a.x*b.x<0) return 3.1415926536;
			else if(abs(a.x)<abs(b.x)){
				return 0;
			}
			else return 6.2831853072;
		}
		else{
			if(a.y*b.y<0) return 3.1415926536;
			else if(abs(a.y)<abs(b.y)){
				return 0;
			}
			else return 6.2831853072;
		}
	}
	ld t1,t2;
	t1=a.x*b.x+a.y*b.y;
	t2=sqrt(a.x*a.x+a.y*a.y)*sqrt(b.x*b.x+b.y*b.y);
//	printf("t1/t2=%Lf acos=%Lf\n",t1/t2,acos(t1/t2));
	if(len>0) return acos(t1/t2);
	else return 6.2831853072-acos(t1/t2);
}
void slove(){
	st1.clear();
	st2.clear();
	st.clear();
	ll n,k;
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;i++){
		scanf("%lf%lf",&t[i].x,&t[i].y);
		if(t[i].y==0){
			if(t[i].x>0) st1.push_back(t[i]);
			else st2.push_back(t[i]);
		}
		else if(t[i].y>0){
			st1.push_back(t[i]);
		}
		else{
			st2.push_back(t[i]);
		}
	}
	sort(st1.begin(),st1.end(),cmp1);
	sort(st2.begin(),st2.end(),cmp1);
	for(int i=0;i<st1.size();i++){
		st.push_back(st1[i]);
	}
	for(int i=0;i<st2.size();i++){
		st.push_back(st2[i]);
	}
	for(int i=0;i<k;i++){
		st.push_back(st[i]);
	}
//	printf("\n\n\n");
//	for(int i=0;i<st.size();i++){
//		printf("%d %lf %lf\n",i,st[i].x,st[i].y);
//	}
//	printf("\n\n\n");
	ld ans=0;
	for(int i=0;i<n;i++){
		ans=max(ans,ccal(st[i],st[i+k]));
	}
	printf("%.11lf\n",ans);
	return ;
}
int main(){
	int T;
	scanf("%d",&T);
	while(T--) slove();
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 4192kb

input:

5
1 1
0 1
8 2
1 0
1 1
0 1
-1 1
-1 0
-1 -1
0 -1
1 -1
4 2
-1 1
0 1
0 2
1 1
4 2
-1000000000 0
-998244353 1
998244353 1
1000000000 0
3 1
0 1
0 2
0 -1

output:

6.28318530720
1.57079632679
5.49778714380
3.14159265361
3.14159265360

result:

ok 5 numbers

Test #2:

score: -100
Wrong Answer
time: 31ms
memory: 4420kb

input:

10000
16 1
-10 -6
-5 -6
-4 9
-2 5
-2 10
1 -7
1 -5
1 6
3 1
4 -9
6 -10
6 -3
6 1
8 -5
8 -4
9 -4
17 4
-9 2
-8 -4
-8 -3
-8 -1
-6 -2
-6 -1
-6 8
-5 -8
-5 10
-4 8
-2 -8
4 -9
4 0
5 -3
8 -5
9 -2
10 10
10 6
-7 2
-4 6
-2 -7
-2 -1
-1 7
1 -9
1 8
3 -4
7 -4
9 -2
14 3
-9 10
-8 -10
-8 -8
-6 -7
-6 -5
-1 -7
-1 -2
0 -1
...

output:

1.69299149749
2.57486343607
4.65275826727
2.77263310738
5.74276580693
4.85769899104
3.41989231262
2.81279996208
6.28318530720
6.28318530720
5.11728076669
6.14678270280
3.84208902356
2.34249671682
3.46334320801
6.28318530720
5.96143475280
3.32470347087
5.26277492808
5.67245934281
1.67387793532
1.1141...

result:

wrong answer 494th numbers differ - expected: '1.1928280', found: '6.2831853', error = '4.2674696'