QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#804401#9869. Horizon Scanningucup-team139#WA 26ms3848kbC++14807b2024-12-07 22:19:402024-12-07 22:19:42

Judging History

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

  • [2024-12-07 22:19:42]
  • 评测
  • 测评结果:WA
  • 用时:26ms
  • 内存:3848kb
  • [2024-12-07 22:19:40]
  • 提交

answer

#include <bits/stdc++.h>

#define int int64_t
using namespace std;

const long double PI = acos((long double)-1);

void solve () {
	int n,k;
	cin>>n>>k;
	vector<long double> a(n);
	for(int i=0; i<n; ++i) {
		int x,y;
		cin>>x>>y;
		if(x==0) {
			a[i] = y>0?0.0:PI;
		} else if (y==0) {
			a[i] = x>0?PI/2.0:3.0*PI/2.0;
		} else {
			a[i] = atan((long double)y/(long double)x);
			if(x<0 && y<0) {
				a[i]+=PI;
			}
			if(x<0 && y>0) {
				a[i]+=PI;
			}
			if(x>0 && y<0) {
				a[i]+=2.0*PI;
			}
		}
	}
	sort(a.begin(),a.end());
	long double res = 0;
	for(int i=0; i<n; ++i) {
		long double ar = i+k<n?a[i+k]:(a[i+k-n]+2.0*PI);
		res=max(res,ar-a[i]);
	}
	cout<<setprecision(17)<<res<<'\n';
}

signed main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	int t;
	cin>>t;
	while(t--)solve();
	return 0;
}


詳細信息

Test #1:

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

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.2831853071795865
1.5707963267948966
5.4977871437821382
3.1415926555933107
3.1415926535897932

result:

ok 5 numbers

Test #2:

score: -100
Wrong Answer
time: 26ms
memory: 3848kb

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.6929914974862517
2.5748634360662869
4.6527582672535205
2.5415424401880397
5.3558900891779742
4.6314848812294593
3.7786629828654768
2.8127999620848389
6.2831853071795865
6.2831853071795865
5.1172807666697733
6.158830312632825
3.8420890235375196
2.2318394956455835
3.4633432079864354
6.28318530717958...

result:

wrong answer 4th numbers differ - expected: '2.7726331', found: '2.5415424', error = '0.0833470'