QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#730488#9576. Ordainer of Inexorable Judgmentucup-team4975WA 0ms3924kbC++234.1kb2024-11-09 20:25:422024-11-09 20:25:46

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 20:25:46]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3924kb
  • [2024-11-09 20:25:42]
  • 提交

answer

#define LOCAL
#include <bits/stdc++.h>
#define fir first
#define sec second
#define el '\n'

#ifdef LOCAL
#define FINISH cerr << "FINISH" << endl;
#else
#define FINISH ;
#endif

#ifdef LOCAL
#define debug(x) cerr << setw(4) << #x << " == " << x << endl
#else
#define debug(x)
#endif

#ifdef LOCAL
#define debugv(x)                   \
	cerr << setw(4) << #x << ":: "; \
	for (auto i : x)                \
		cerr << i << " ";           \
	cerr << endl
#else
#define debugv(x)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ld, ld> PII;
ostream &operator<<(ostream &out, PII &x)
{
	out << x.fir << " " << x.sec << endl;
	return out;
}

const int mod = 998244353;
const int inf = 0x3f3f3f3f;
const int N = 200020;
const ld eps = 1e-12;
struct point {
	ld x, y;
	point operator+(const point &a) const
	{
		return {x + a.x, y + a.y};
	}
	point operator-(const point &a) const
	{
		return {x - a.x, y - a.y};
	}
	ld operator*(const point &a) const
	{
		return {x * a.x + y * a.y};
	}
	ld operator^(const point &a) const
	{
		return {x * a.y - y * a.x};
	}  // 注意优先级
	int toleft(const point &a) const
	{
		const auto t = (*this) ^ a;
		return (t > eps) - (t < -eps);
	}
	long double len2() const
	{
		return (*this) * (*this);
	}
	long double len() const
	{
		return sqrtl(len2());
	}
	long double angle(const point &a) const
	{
		return acosl(max(-1.0l, min(1.0l, ((*this) * a) / (len() * a.len()))));
	}
};
const ld pi = 3.1415926535897932384626433;
void solve()
{
	int n, x0, y0, d, t, flag1 = 1, flag2 = 1;
	cin >> n >> x0 >> y0 >> d >> t;
	if (x0 < 0) {
		flag1 = -1;
	}
	if (y0 < 0) {
		flag2 = -1;
	}
	vector<point> ang;
	auto getang = [&](ld x, ld y) {
		pair<point, point> r;
		ld L = sqrt(x * x + y * y);
		ld Y = d;
		ld X = sqrt(x * x + y * y - d * d);
		ld cosx = X / L, sinx = Y / L;
		r.sec = point(x * cosx - y * sinx, x * sinx + y * cosx);
		r.fir = point(x * cosx + y * sinx, -x * sinx + y * cosx);
		ang.push_back(r.fir);
		ang.push_back(r.sec);
	};
	for (int i = 1; i <= n; i++) {
		ld x, y;
		cin >> x >> y;
		x = x * flag1, y = y * flag2;
		getang(x, y);
	}

	// for (int i = 0; i < ang.size(); i++) {
	// 	cout << ang[i].x << " " << ang[i].y << endl;
	// }

	int l;
	for (int i = 0; i < ang.size(); i++) {
		int flag = 1;
		for (int j = 0; j < ang.size(); j++) {
			// cout << ang[i].toleft(ang[j]) << endl;
			if (ang[i].toleft(ang[j]) == -1) {
				flag = 0;
				break;
			}
		}
		if (flag == 1) {
			l = i;
			break;
		}
	}
	int r;
	for (int i = 0; i < ang.size(); i++) {
		int flag = 1;
		for (int j = 0; j < ang.size(); j++) {
			if (j == i)
				continue;
			if (ang[i].toleft(ang[j]) == 1) {
				flag = 0;
				break;
			}
		}
		if (flag == 1) {
			r = i;
			break;
		}
	}

	/*cout << l << " " << r << endl;
	cout << ang[l].x << " " << ang[l].y << " " << ang[r].x << " " << ang[r].y
		 << endl;*/
	ld a = ang[l].angle(ang[r]);
	ld ans = a * floor(t / pi / 2);
	ld lft = t - floor(t / pi / 2) * pi * 2;

	point st = point(x0, y0);

	ld cosx = x0 / sqrtl(x0 * x0 + y0 * y0);
	ld sinx = y0 / sqrtl(x0 * x0 + y0 * y0);
	ang[l] = point(ang[l].x * cosx + ang[l].y * sinx,
				   -ang[l].x * sinx + ang[l].y * cosx);
	ang[r] = point(ang[r].x * cosx + ang[r].y * sinx,
				   -ang[r].x * sinx + ang[r].y * cosx);

	ld ang1 = ang[l].angle(point(1, 0));
	ld ang2 = ang[r].angle(point(1, 0));

	if (ang[l].y < -eps)
		ang1 = pi * 2 - ang1;
	if (ang[r].y < -eps)
		ang2 = pi * 2 - ang2;

	/*cout << ang1 << " " << ang2 << endl;
	cout << ans << endl;
	cout << lft << " " << ang1 << " " << ang2 << endl;*/
	if (ang2 < pi && ang1 > pi) {
		if (lft > ang2) {
			ans += ang2;
		}
		if (lft > ang1) {
			ans += lft - ang1;
		}
	}
	else {
		if (lft > ang2) {
			ans += a;
		}
		else if (lft > ang1) {
			ans += lft - ang1;
		}
	}
	cout << fixed << setprecision(12) << ans << endl;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	// cin >> T;
	while (T--) {
		solve();
	}
	return 0;
}

詳細信息

Test #1:

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

input:

3 1 0 1 1
1 2
2 1
2 2

output:

1.000000000000

result:

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

Test #2:

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

input:

3 1 0 1 2
1 2
2 1
2 2

output:

1.570796326795

result:

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

Test #3:

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

input:

3 1 0 1 10000
1 2
2 1
2 2

output:

2500.707752257475

result:

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

Test #4:

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

input:

3 10000 10000 1 10000
10000 9999
10000 10000
9999 10000

output:

0.384241300290

result:

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

Test #5:

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

input:

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

output:

2500.551253633297

result:

wrong answer 1st numbers differ - expected: '2500.2406700', found: '2500.5512536', error = '0.0001242'