QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#187323#3854. Radarballance#WA 2ms3812kbC++171.4kb2023-09-24 16:23:242023-09-24 16:23:24

Judging History

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

  • [2023-09-24 16:23:24]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3812kb
  • [2023-09-24 16:23:24]
  • 提交

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(int x, int 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];
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);
		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++)
			for(int j=1;j<=2;j++)
			{
				ld dx = s[i] * cos(p[j]), dy = s[i] * sin(p[j]);
				ans = min(ans, len(dx - x, dy - y));
			}
		cout <<fixed<<setprecision(15)<< ans << '\n';
	}
}

詳細信息

Test #1:

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

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: 1ms
memory: 3740kb

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: 3812kb

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
20.615528128149108
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'