QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#729063#9576. Ordainer of Inexorable Judgmentucup-team3510#WA 0ms4340kbC++142.5kb2024-11-09 16:26:122024-11-09 16:26:24

Judging History

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

  • [2024-12-23 14:23:26]
  • hack成功,自动添加数据
  • (/hack/1303)
  • [2024-12-06 11:32:56]
  • hack成功,自动添加数据
  • (/hack/1271)
  • [2024-11-14 21:58:28]
  • hack成功,自动添加数据
  • (/hack/1181)
  • [2024-11-09 16:26:24]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4340kb
  • [2024-11-09 16:26:12]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
typedef long double ld;

const ld pi = acosl(-1), eps = 1e-9;
struct vec
{
	ld x, y;
	vec(ld x0 = 0, ld y0 = 0)
	{
		x = x0;
		y = y0;
	}
	vec operator + (vec v)
	{
		return vec(x + v.x, y + v.y);
	}
	vec operator - (vec v)
	{
		return vec(x - v.x, y - v.y);
	}
	vec operator * (ld k)
	{
		return vec(x * k, y * k);
	}
	ld dis2()
	{
		return x * x + y * y;
	}
	void print()
	{
		printf("(%.10Lf, %.10Lf)\n", x, y);
	}
};
vec p[105];
ld qwq[205];
pair<vec, vec> haha(vec a, ld b, vec c, ld d) // b, d is dis^2
{
	c = c - a;
	ld p = (c.dis2() - d + b) / 2, x, y, u, v, w;
	ld x0, x1;
	if(abs(c.y) < eps)
	{
		x = p / c.x;
		y = sqrtl(b - x * x);
		return make_pair(a + vec(x, y), a + vec(x, -y));
	}
	u = c.dis2();
	v = -2 * p * c.x;
	w = p * p - b * c.y * c.y;
	x0 = (-v + sqrtl(v * v - 4 * u * w)) / (2 * u);
	x1 = (-v - sqrtl(v * v - 4 * u * w)) / (2 * u);
	return make_pair(a + vec(x0, (p - c.x * x0) / c.y), a + vec(x1, (p - c.x * x1) / c.y));
}

int main()
{
	int n, x0, y0, d, t, i, j, c = 0;
	vec u, v;
	ld l, r, L, R, pl, pr, ans = 0;
	L = 2 * pi;
	R = 0;
	scanf("%d%d%d%d%d", &n, &x0, &y0, &d, &t);
	pl = atan2(y0, x0);
	for(i = 1; i <= n; i++)
	{
		scanf("%Lf%Lf", &p[i].x, &p[i].y);
		u = (vec(0, 0) + p[i]) * 0.5;
		auto o = haha(vec(0, 0), (ld)d * d, u, u.dis2());
		u = o.first;
		v = o.second;
		// printf("#%d\n", i);
		// u.print();
		// v.print();
		if(u.x * v.y < u.y * v.x)
			swap(u, v);
		l = atan2(v.y, v.x) - pi / 2;
		r = atan2(u.y, u.x) + pi / 2;
		l -= floor(l / (2 * pi)) * (2 * pi);
		r -= floor(r / (2 * pi)) * (2 * pi);
		qwq[++c] = l;
		qwq[++c] = r;
		// printf("#%.10Lf %.10Lf\n", l, r);
	}
	sort(qwq + 1, qwq + c + 1);
	for(i = 1; i <= c; i++)
		qwq[i + c] = qwq[i] + 2 * pi;
	L = R = -1;
	for(i = 1; i <= c; i++)
		if(qwq[i + c - 1] - qwq[i] <= pi)
		{
			L = qwq[i];
			R = qwq[i + c - 1];
			if(R > 2 * pi)
				R -= 2 * pi;
			break;
		}
	pr = pl + t;
	for(i = 0; i < 10000; i++)
		if(L <= R)
		{
			if(max(L + i * 2 * pi, pl) < min(R + i * 2 * pi, pr))
				ans += min(R + i * 2 * pi, pr) - max(L + i * 2 * pi, pl);
		}
		else
		{
			l = i * 2 * pi;
			r = L + l;
			if(max(l, pl) < min(r, pr))
				ans += min(r, pr) - max(l, pl);
			l = i * 2 * pi + R;
			r = (i + 1) * 2 * pi;
			if(max(l, pl) < min(r, pr))
				ans += min(r, pr) - max(l, pl);
		}
	printf("%.10Lf\n", ans);
	return 0;
}
/*
3 1 0 1 1
1 2
2 1
2 2
*/

详细

Test #1:

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

input:

3 1 0 1 1
1 2
2 1
2 2

output:

1.0000000000

result:

ok found '1.0000000', expected '1.0000000', error '0.0000000'

Test #2:

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

input:

3 1 0 1 2
1 2
2 1
2 2

output:

1.5707963268

result:

ok found '1.5707963', expected '1.5707963', error '0.0000000'

Test #3:

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

input:

3 1 0 1 10000
1 2
2 1
2 2

output:

2500.7077522575

result:

ok found '2500.7077523', expected '2500.7077523', error '0.0000000'

Test #4:

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

input:

3 10000 10000 1 10000
10000 9999
10000 10000
9999 10000

output:

0.3842413003

result:

ok found '0.3842413', expected '0.3842413', error '0.0000000'

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 4264kb

input:

3 -10000 -10000 10000 10000
-10000 -9999
-10000 -10000
-9999 -10000

output:

2499.4551718412

result:

wrong answer 1st numbers differ - expected: '2500.2406700', found: '2499.4551718', error = '0.0003142'