QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#804105#9869. Horizon Scanningucup-team1338#TL 563ms4276kbC++201.6kb2024-12-07 20:28:122024-12-07 20:28:12

Judging History

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

  • [2024-12-07 20:28:12]
  • 评测
  • 测评结果:TL
  • 用时:563ms
  • 内存:4276kb
  • [2024-12-07 20:28:12]
  • 提交

answer

#include<bits/stdc++.h>
#define LL long long
#define len(G) (LL)(G).size()
#define all(G) (G).begin(),(G).end()
#define ar(n) array<LL,n>
using namespace std;
using i128=__int128;
using ar=array<LL,2>;
using Poly=vector<LL>;

mt19937_64 rnd(random_device{}());

constexpr LL N=2e5+9;
constexpr double eps=1e-10;
using numbers::pi;

LL n,K;
double t[N];

template<class T>
inline void read(T &x)
{
	x=0;int w=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')w=-1;	c=getchar();}
	while(isdigit(c)){x=x*10+(c^'0');	c=getchar();}
	if(w==-1)	x=-x;
}
template<class T,class... Args>
inline void read(T &x,Args &...args)
{
	read(x),read(args...);
}

double ang(double x,double y)
{
	double t=atan2(y,x);
	if(t<0)	t+=2*pi;
	return t;
}

map<double,LL> mp;
void add(double l,double r)
{
	++mp[l-eps];
	--mp[r+eps];
}

bool check(double a)
{
	mp.clear();
	mp[2*pi+eps]=0;
	for(LL i=1;i<=n;++i)
	{
		double l=t[i]-a/2,r=t[i]+a/2;
		if(l<0)
		{
			add(0,r);
			add(l+2*pi,2*pi);
		}
		else if(r>2*pi)
		{
			add(0,r-2*pi);
			add(l,2*pi);
		}
		else
		{
			add(l,r);
		}
	}
	if(mp.begin()->first>0)	return 0;
	LL cur=0;
	for(auto [k,v]:mp)
	{
		if(k>0&&cur<K)	return 0;
		if(k>2*pi)	break;
		cur+=v;
	}
	return 1;
}

void solve()
{
	read(n,K);
	for(LL i=1;i<=n;++i)
	{
		LL x,y;
		read(x,y);
		t[i]=ang(x,y);
	}
	double l=0,r=2*pi;
	for(LL _=1;_<=40;++_)
	{
		double mid=(l+r)/2;
		if(check(mid))	r=mid;
		else	l=mid;
	}
	printf("%.10lf\n",l);
}

int main()
{
	LL T;
	read(T);
	while(T--)	solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 4232kb

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.2831853070
1.5707963266
5.4977871436
3.1415926544
3.1415926534

result:

ok 5 numbers

Test #2:

score: 0
Accepted
time: 542ms
memory: 4176kb

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.6929914973
2.5748634359
4.6527582671
2.7726331072
5.7427658067
4.8576989908
3.4198923124
2.8127999619
6.2831853070
6.2831853070
5.1172807665
6.1467827026
3.8420890233
2.3424967166
3.4633432078
6.2831853070
5.9614347526
3.3247034707
5.2627749279
5.6724593426
1.6738779351
1.1141908547
2.4087775516
6...

result:

ok 10000 numbers

Test #3:

score: 0
Accepted
time: 547ms
memory: 4148kb

input:

10000
19 7
-10 -6
-10 5
-3 0
-2 -5
-1 1
-1 6
0 3
0 7
1 9
3 -3
3 3
3 8
4 -1
5 8
6 -3
7 -5
7 4
8 10
9 -5
15 15
-9 -1
-8 6
-7 9
-6 -3
-4 -9
-1 -3
-1 8
1 -8
1 -7
3 -2
3 1
6 -9
7 -10
7 0
10 -9
10 3
-7 -1
-6 -2
-6 10
-5 2
-4 2
-3 -7
-2 -9
1 -3
3 4
7 7
15 4
-8 -8
-8 8
-7 0
-7 10
-6 -7
-5 6
-1 -3
-1 0
1 -2
...

output:

3.9269908168
6.2831853070
3.3602615993
2.6779450444
3.7703889398
1.7625844686
3.8402524781
5.4977871436
2.0344439356
1.8157749897
4.3471875304
6.1412882524
5.1760365892
5.4655402611
5.7690391511
4.3662530166
5.9947557485
4.8922424800
4.1719694799
5.6776406434
5.9614347526
3.5067941032
4.5429759363
5...

result:

ok 10000 numbers

Test #4:

score: 0
Accepted
time: 545ms
memory: 4200kb

input:

10000
18 12
-10 -4
-10 7
-8 -10
-7 -4
-6 5
-6 7
-5 0
-2 -7
-1 2
-1 10
0 2
1 1
3 -2
5 3
5 5
6 -3
8 -3
9 -2
10 1
-10 -9
-7 -7
-5 2
-4 -7
-3 1
3 1
3 3
5 -4
9 2
9 6
11 2
-8 1
-8 6
-7 -2
-6 0
-5 0
-1 -9
2 -8
3 5
6 0
10 -2
10 6
20 9
-10 -6
-10 6
-9 -8
-7 5
-6 -4
-4 -8
-2 -10
-2 -3
-2 4
-1 1
2 -5
3 -2
5 -6...

output:

4.9097845400
1.9756881129
1.9868608323
3.9269908168
3.6977588835
6.2831853070
6.1412882524
6.1938713140
5.8053542520
6.2528915471
5.7288778108
3.0900918424
1.8925468810
5.6341897480
2.8966139903
6.2831853070
2.9147938053
6.1476575930
1.9513027037
5.5643553074
5.4977871436
3.0981417580
4.3906384258
3...

result:

ok 10000 numbers

Test #5:

score: 0
Accepted
time: 546ms
memory: 4152kb

input:

10000
19 7
-10 -1
-8 2
-7 -10
-6 6
-4 7
-3 -5
-3 1
-3 8
-2 4
-1 -7
0 -8
0 9
1 -10
2 1
2 3
3 5
6 -4
10 2
10 3
14 10
-8 2
-6 0
-5 -10
-5 10
-4 7
-3 -6
-2 -6
1 4
1 6
2 -1
3 -6
8 -4
9 -10
10 -1
12 8
-9 5
-7 2
-4 2
0 -2
0 5
1 6
3 2
4 9
5 5
7 -6
9 -9
9 2
19 12
-10 -10
-10 2
-9 -6
-8 2
-7 -5
-6 8
-4 1
-1 -...

output:

3.2393195607
5.2757052417
5.3003915837
5.3871299224
5.8883941873
4.1173193565
1.1383885510
1.5152978213
6.1476575930
6.1588303124
2.5748634359
5.9401613666
1.6085142791
4.6099451267
5.0711596505
4.2345579252
3.7905882124
4.0376480380
3.9160022481
1.0636978222
4.2809882536
5.8572556504
3.4078447025
5...

result:

ok 10000 numbers

Test #6:

score: 0
Accepted
time: 548ms
memory: 4276kb

input:

10000
11 10
-10 -1
-9 4
-9 10
-7 -7
-5 4
-4 -1
-2 -10
0 -7
0 5
3 3
3 5
12 12
-9 6
-9 8
-3 -2
-2 2
0 -4
1 0
2 -3
3 5
5 -2
7 -1
10 3
10 9
14 12
-10 0
-9 -3
-9 1
-9 10
-8 -1
-8 7
-6 -1
-1 -6
-1 2
1 -1
3 -7
4 9
9 -3
10 1
10 4
-9 -3
-7 -1
-6 -10
-3 -2
-3 7
2 -2
2 3
5 2
6 9
9 6
10 2
-9 -9
-9 6
-8 3
-5 -9
...

output:

6.1378752963
6.2831853070
6.1180366296
3.2003484761
2.6537562147
6.2537820188
3.6052402624
3.5598169830
1.5091461560
5.9275494227
6.2587998978
2.6224465391
4.3938333031
5.4977871436
4.2487413712
5.4977871436
4.6292477483
3.5464844397
6.0048856480
1.1967518951
2.8854412708
6.2000440751
1.9237867144
5...

result:

ok 10000 numbers

Test #7:

score: 0
Accepted
time: 563ms
memory: 4044kb

input:

10000
14 1
-100 13
-96 -31
-82 -92
-77 -98
-50 1
-14 -57
-14 -31
-11 64
-8 75
9 68
25 100
54 -36
59 13
93 31
19 19
-76 -39
-60 95
-51 18
-39 11
-21 -46
-6 -94
-5 83
-3 -34
-3 72
0 -55
3 79
14 17
23 -88
32 37
50 70
61 -5
62 -43
84 -100
97 -50
13 7
-99 -63
-68 -87
-24 62
-20 -18
-2 -66
7 -49
13 -21
15...

output:

1.2713093973
6.2831853070
5.2225147205
6.0030657034
3.9258721353
5.5465289949
3.2103149235
3.0399300497
4.2275317816
3.0320196655
2.1912152336
3.0390080902
4.3313271504
6.2831853070
5.1100022648
2.9463140259
5.1760365892
5.6991835712
2.0611798649
6.2831853070
2.2278897853
6.1707748614
6.2831853070
6...

result:

ok 10000 numbers

Test #8:

score: -100
Time Limit Exceeded

input:

100
1413 755
-30 -30
-30 -28
-30 -27
-30 -26
-30 -21
-30 -12
-30 -10
-30 -8
-30 -5
-30 -1
-30 2
-30 4
-30 7
-30 9
-30 17
-30 19
-30 20
-30 23
-30 24
-30 30
-29 -29
-29 -23
-29 -15
-29 0
-29 4
-29 5
-29 9
-29 10
-29 11
-29 12
-29 14
-29 16
-29 17
-29 22
-29 27
-29 28
-28 -28
-28 -25
-28 -23
-28 -22
-...

output:


result: