QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#187071#3854. RadarSuiseiseki#WA 4ms8012kbC++142.7kb2023-09-24 14:18:042023-09-24 14:48:00

Judging History

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

  • [2023-09-24 14:48:00]
  • 管理员手动重测本题所有提交记录
  • 测评结果:WA
  • 用时:4ms
  • 内存:8012kb
  • [2023-09-24 14:18:05]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:7824kb
  • [2023-09-24 14:18:04]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using db = double;

const int mxn = 1e5 + 5;

struct Point
{
	int x, y;
	Point(): x(), y() {}
	Point(int _x, int _y): x(_x), y(_y) {}
	
	ll dot(const Point &oth) const
	{
		return 1LL * x * oth.x + 1LL * y * oth.y;
	}
	
	ll det(const Point &oth) const
	{
		return 1LL * x * oth.y - 1LL * y * oth.x;
	}
	
	int type() const
	{
		if (x >= 0 && y > 0) return 1;
		if (x < 0 && y >= 0) return 2;
		if (x <= 0 && y < 0) return 3;
		if (x > 0 && y <= 0) return 4;
		return 0;
	}
	
	friend ostream& operator << (ostream &o, const Point &p)
	{
		return o << "(" << p.x << ", " << p.y << ")";
	}
};

void chk(Point vec, db rad, Point p, db &res)
{
	db len = sqrt(1LL * vec.x * vec.x + 1LL * vec.y * vec.y);
	db x = vec.x / len, y = vec.y / len;
	x *= rad, y *= rad;
	res = min(res, sqrt((x - p.x) * (x - p.x) + (y - p.y) * (y - p.y)));
}

int R, F, n;
ll r[mxn];
int fx[mxn], fy[mxn];
int qx[mxn], qy[mxn];
Point fp[mxn], qp[mxn];
int id[mxn], idq[mxn];

bool comp_angle(const Point &a, const Point &b)
{
	if (a.type() != b.type()) return a.type() < b.type();
	return a.det(b) > 0;
}

bool comp_query(int a, int b)
{
	return comp_angle(qp[a], qp[b]);
}

int sgn(ll x)
{
	return x < 0 ? -1 : x == 0 ? 0 : +1;
}

db ans[mxn];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> R >> F >> n;
	for (int i = 0; i < R; ++ i) cin >> r[i], r[i] = r[i] * r[i];
	for (int i = 0; i < F; ++ i) cin >> fx[i] >> fy[i], fp[i] = Point(fx[i], fy[i]);
	sort(r, r + R);
	sort(fp, fp + F, comp_angle);
//	for (int i = 0; i < F; ++ i) cerr << fp[i] << " ";
//	cerr << endl;
	for (int i = 0; i < n; ++ i) cin >> qx[i] >> qy[i], qp[i] = Point(qx[i], qy[i]);
	iota(idq, idq + n, 0);
	sort(idq, idq + n, comp_query);
	int J = F - 1;
	for (int i = 0; i < n; ++ i)
	{
		int I = idq[i];
//		int J0 = (J + 1) % F;
//		if (F > 1) while (sgn(qp[I].det(fp[J])) * sgn(qp[I].det(fp[J0])) >= 0)
//		{
//			if (qp[I].det(fp[J]) == 0 && qp[I].dot(fp[J]) >= 0) break;
//			J = J0, J0 = (J + 1) % F;
//		}
		J = upper_bound(fp, fp + F, qp[I], comp_angle) - fp;
		J = (J + F - 1) % F;
		int J0 = (J + 1) % F;
//		cerr << qp[i] << "	-	" << fp[J] << " " << fp[J0] << endl;
		int T = lower_bound(r, r + R, 1LL * qp[I].x * qp[I].x + 1LL * qp[I].y * qp[I].y) - r;
		ans[I] = 1e18;
		if (T > 0) chk(fp[J], sqrt(r[T - 1]), qp[I], ans[I]), chk(fp[J0], sqrt(r[T - 1]), qp[I], ans[I]);
		if (T < R) chk(fp[J], sqrt(r[T]), qp[I], ans[I]), chk(fp[J0], sqrt(r[T]), qp[I], ans[I]);
	}
	cout << fixed << setprecision(12);
	for (int i = 0; i < n; ++ i) cout << ans[i] << endl;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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.605291072917
0.977772290466
1.551845105402
1.414213562373

result:

ok 4 numbers

Test #2:

score: 0
Accepted
time: 1ms
memory: 6400kb

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.874985099258
15.874985099258
15.874985099258
15.874985099258
15.874985099258
15.874985099258
15.874985099258
15.874985099258
4.929656701046
4.929656701046
4.929656701046
4.929656701046
4.929656701046
4.929656701046
4.929656701046
4.929656701046
2.000000000000
2.000000000000
2.000000000000
2.00000...

result:

ok 32 numbers

Test #3:

score: 0
Accepted
time: 4ms
memory: 8012kb

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.055385138137
4.123105625618
3.605551275464
11.045361017187
15.297058540778
1.414213562373
8.246211251235
7.000000000000
8.944271909999
3.000000000000
12.165525060596
5.000000000000
5.099019513593
11.180339887499
1.414213562373
2.000000000000
2.000000000000
3.000000000000
3.162277660168
8.246211251...

result:

ok 1681 numbers

Test #4:

score: 0
Accepted
time: 4ms
memory: 6308kb

input:

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

output:

11.777372119304
4.631593682590
6.895656100977
12.291422905367
6.555964003581
4.270304206047
4.392536000448
6.367825885745
6.555964003581
2.990316379371
10.187520359495
2.833626166509
2.977064831365
4.696779860162
4.352239888693
11.328455809797
3.384030147710
1.836459365744
2.947251516416
7.635131895...

result:

ok 1681 numbers

Test #5:

score: 0
Accepted
time: 1ms
memory: 7968kb

input:

1 4 16
7
0 1
1 0
0 -1
-1 0
3 0
0 3
-3 0
0 -3
3 3
3 -3
-3 3
-3 -3
8 0
0 8
-8 0
0 -8
8 8
8 -8
-8 8
-8 -8

output:

4.000000000000
4.000000000000
4.000000000000
4.000000000000
5.000000000000
5.000000000000
5.000000000000
5.000000000000
1.000000000000
1.000000000000
1.000000000000
1.000000000000
8.062257748299
8.062257748299
8.062257748299
8.062257748299

result:

ok 16 numbers

Test #6:

score: -100
Wrong Answer
time: 1ms
memory: 6384kb

input:

30 4 120
128
1
2
256
4
512
1024
2048
8
4096
32768
131072
262144
524288
8192
268167
16
536334
16384
1047
32
2095
8380
64
134083
65536
4190
67041
33520
16760
536334 0
-536335 0
0 536334
0 -536335
-1 1
-2 2
-4 4
-8 8
-16 16
-32 32
-64 64
-128 128
-256 256
-512 512
-1024 1024
-2048 2048
-4096 4096
-8192...

output:

1.000000000000
2.000000000000
4.000000000000
8.000000000000
16.000000000000
32.000000000000
64.000000000000
128.000000000000
256.000000000000
512.000000000000
1024.258268211685
2048.539235650614
4097.078471301227
8194.156942602454
16388.313885204909
32776.627770409817
65553.278491620847
131106.57994...

result:

wrong answer 11th numbers differ - expected: '1024.0000000', found: '1024.2582682', error = '0.0002522'