QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#187057#3854. RadarSuiseiseki#WA 1ms7740kbC++142.5kb2023-09-24 14:11:112023-09-24 14:47:56

Judging History

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

  • [2023-09-24 14:47:56]
  • 管理员手动重测本题所有提交记录
  • 测评结果:WA
  • 用时:1ms
  • 内存:7740kb
  • [2023-09-24 14:11:11]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:5976kb
  • [2023-09-24 14:11:11]
  • 提交

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;
		}
//		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(10);
	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: 0
Wrong Answer
time: 1ms
memory: 7740kb

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:

3.1622776602
0.9777722905
8.6023252670
1.4142135624

result:

wrong answer 1st numbers differ - expected: '0.6052911', found: '3.1622777', error = '2.5569866'