QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#187367#3854. Radarballance#WA 2ms3916kbC++172.1kb2023-09-24 16:40:252023-09-24 16:40:26

Judging History

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

  • [2023-09-24 16:40:26]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3916kb
  • [2023-09-24 16:40:25]
  • 提交

answer

#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>
using namespace std;
typedef long long ll;
typedef long double ld;
const ld PI = 3.14159265358;
ld angle(ld x, ld y)
{
	if (x == 0)
	{
		if (y > 0)
			return PI / 2;
		return -PI / 2;
	}
	if (x > 0)
		return atan(ld(y) / x);
	else
		if (y < 0)return -PI + atan(ld(y) / x);
		else
			return PI + atan(ld(y) / x);
}
ld len(ld x, ld y)
{
	return sqrt(x * x + y * y);
}
const int N = 100010;

int r[N];
ld a[N];
ld len2(ld alpha, ld r, ld x, ld y)
{
	ld dx = r * cos(alpha), dy = r * sin(alpha);
	return len(dx - x, dy - y);
}
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); 
	cout.tie(0);
	int rr, ff, tt;
	cin >> rr >> ff >> tt;
	for (int i = 1; i <= rr; i++)
		cin >> r[i];
	sort(r + 1, r + rr + 1);
	r[0] = -1e8;
	r[rr + 1] = 1e8;
	for (int i = 1; i <= ff; i++)
	{
		int x, y; cin >> x >> y;
		a[i] = angle(x, y);
		//cout << x << ' ' << y << ' ' << a[i] << '\n';
	}
	sort(a + 1, a + ff + 1);
	a[ff + 1] = a[1] + 2 * PI;
	while (tt--)
	{
		int x, y; cin >> x >> y;
		ld leng = len(x, y);
		/*int l = lower_bound(r, r + rr + 2, leng) - r;
		int s[3];
		s[1] = r[l - 1], s[2] = r[l];*/
		ld alpha = angle(x, y);
		int l = lower_bound(a + 1, a + ff + 2, alpha) - a;
		ld p[3];
		p[1] = a[l - 1], p[2] = a[l];
		ld ans = 1e10;
		for (int i = 1; i <= 2; i++)
		{
			ld beta = p[i];
			ld shadowlen = leng * cos(beta - alpha);
			int l = lower_bound(r, r + rr + 2, shadowlen) - r;
			int s[3];
			s[1] = r[l - 1], s[2] = r[l];
			for (int j = 1; j <= 2; j++)
				ans = min(ans, len2(beta, s[j], x, y));
			/*int step = 1;
			int cnt = 0;
			ld cntlen = 1e9;;
			int n = rr + 1;
			while (step)
			{
				while (cnt + step > n)
					step /= 2;
				ld nowlen = len2(beta, r[cnt + step], x, y);
				if (nowlen < cntlen)
					cntlen = nowlen, cnt += step, step *= 2;
				else
					step /= 2;
			}
			ld mini = cntlen;
			mini = min(mini, len2(beta, r[cnt + 1], x, y));*/
		}
		cout <<fixed<<setprecision(15)<< ans << '\n';
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 8 4
2
4
7
1 0
2 1
0 1
-1 1
-5 -2
-5 -6
-2 -7
6 -1
-1 -1
3 1
-5 -3
8 1

output:

0.605291072920783
0.977772290465605
1.551845105360774
1.414213562373095

result:

ok 4 numbers

Test #2:

score: 0
Accepted
time: 0ms
memory: 3908kb

input:

1 8 32
7
0 1
1 0
0 -1
-1 0
1 -1
-1 1
-1 -1
1 1
20 10
10 20
-20 10
10 -20
-10 20
20 -10
-10 -20
-20 -10
2 1
1 2
-2 1
1 -2
-1 2
2 -1
-1 -2
-2 -1
5 0
0 5
-5 0
0 -5
5 5
5 -5
-5 5
-5 -5
9 0
0 9
-9 0
0 -9
9 9
9 -9
-9 9
-9 -9

output:

15.874985099257575
15.874985099257575
15.874985099288110
15.874985099257575
15.874985099227040
15.874985099257575
15.874985099227040
15.874985099288110
4.929656701045723
4.929656701045723
4.929656701055556
4.929656701045723
4.929656701035890
4.929656701045723
4.929656701035890
4.929656701055556
2.00...

result:

ok 32 numbers

Test #3:

score: -100
Wrong Answer
time: 2ms
memory: 3908kb

input:

3 4 1681
16
8
4
-1 0
0 -1
0 1
1 0
-9 17
-4 -7
2 -13
-11 -17
15 -19
-7 1
-8 14
-8 -7
-8 20
-16 -3
12 14
-3 12
9 -5
-18 11
3 -1
2 0
-18 0
0 -19
-1 -19
18 -8
2 20
5 -8
-8 -19
-9 -16
20 -19
14 -1
3 10
-1 -4
4 10
16 17
19 -7
-17 4
1 -12
-5 -12
-5 -10
-15 -5
-10 -19
-2 -10
-4 -16
-2 4
-14 8
-17 16
4 1
16 ...

output:

9.055385138215283
4.123105625655664
3.605551275420531
11.045361017265284
15.297058540701530
1.414213562317696
8.246211251311327
8.062257748337420
8.944271910069233
16.031219541900946
12.165525060519160
5.000000000023504
5.099019513592785
11.180339887344785
1.414213562373095
2.000000000000000
2.00000...

result:

wrong answer 8th numbers differ - expected: '7.0000000', found: '8.0622577', error = '0.1517511'