QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#722612 | #9576. Ordainer of Inexorable Judgment | ucup-team2179 | WA | 0ms | 4208kb | C++20 | 4.0kb | 2024-11-07 19:39:11 | 2024-11-07 19:39:13 |
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-07 19:39:11]
- 提交
answer
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8; // 根据题目精度要求进行修改
const double PI = acos(-1.0); // pai, 3.1415916....
int sgn(double x)
{ // 进行判断, 提高精度
if (fabs(x) < eps)
return 0; // x == 0, 精度范围内的近似相等
return x > 0 ? 1 : -1; // 返回正负
}
// 点和向量<---------------------------------------------->
// Need: sgn()
typedef struct Point
{
double x, y;
Point(double x = 0, double y = 0) : x(x), y(y) {} // 构造函数, 初始值为 0
// 重载运算符
// 点 - 点 = 向量(向量AB = B - A)
Point operator-(const Point &B) const { return Point(x - B.x, y - B.y); }
// 点 + 点 = 点, 点 + 向量 = 向量, 向量 + 向量 = 向量
Point operator+(const Point &B) const { return Point(x + B.x, y + B.y); }
// 向量 × 向量 (叉积)
double operator^(const Point &B) const { return x * B.y - y * B.x; }
// 向量 · 向量 (点积)
double operator*(const Point &B) const { return x * B.x + y * B.y; }
} Vector;
struct Circle
{
Point c;
double r;
Circle(Point c = Point(), double r = 0) : c(c), r(r) {}
};
double len(Vector A) { return sqrt(A * A); }
Vector Rotate(Vector A, double b)
{
Vector B(sin(b), cos(b));
return Vector(A ^ B, A * B);
}
// 点到圆的切线
// 过点p到圆c的切线,v[i]是第i条切线
vector<Vector> get_tangents(Point p, Circle C)
{
Vector u = C.c - p;
double dist = len(u);
if (dist < C.r)
return {}; // 点在内部,没有切线
else if (sgn(dist - C.r) == 0)
{ // p在圆上,只有一条切线
return {Rotate(u, PI / 2)};
}
else
{ // 否则是两条切线
double ang = asin(C.r / dist);
return {Rotate(u, -ang), Rotate(u, +ang)};
}
}
// 判断点在直线的哪边
// Need: (-, ^), sgn()
// 点在直线上, 返回 0 (三点共线)
// 点在直线的逆时针方向, 返回 1
// 点在直线的顺时针方向, 返回 -1
// 点 a, b (向量ab) 所在的直线和点 c
// 使用的时候要注意 a 和 b 的顺序, 有时顺序不同, 结果不同
int Cross(Point a, Point b, Point c) { return sgn((b - a) ^ (c - a)); }
Point a[105];
int n, x, y, d, t;
Circle c;
double col(int op)
{
for (int i = 1; i <= n; i++)
{
vector<Vector> t = get_tangents(a[i], c);
Point q;
for (auto [x, y]: t)
{
x += a[i].x, y += a[i].y;
if (Cross({x, y}, a[i], {0, 0}) == op) q = {x, y};
}
int f = 1;
for (int j = 1; j <= n; j++)
{
if (i == j) continue;
if (Cross(q, a[i], a[j]) == op)
{
f = 0;
break;
}
}
if (f)
{
double jd = atan2(a[i].y - q.y, a[i].x - q.x);
return jd;
}
}
return 0.0;
}
void solve()
{
cin >> n >> x >> y >> d >> t;
c = {{0, 0}, (double)d};
double cs = atan2(y, x);
for (int i = 1; i <= n; i++) cin >> a[i].x >> a[i].y;
// 开始受到伤害
double s = col(-1), e = col(1);
if (s < 0) s += 2 * PI;
if (e < 0) e += 2 * PI;
if (cs < 0) cs += 2 * PI;
if (s > e) e += 2 * PI;
double zh = (int)(t / (2 * PI));
double sh = t - (2 * PI) * zh;
double ans = zh * (e - s);
cout << ans << '\n';
if (cs < s) ans += max(0.0, min(e, cs + sh) - s);
else if (cs < e) ans += max(0.0, min(e, cs + sh) - cs);
else
{
s += 2 * PI, e += 2 * PI;
ans += max(0.0, min(e, cs + sh) - s);
}
cout << fixed << setprecision(10) << ans << '\n';
}
signed main()
{
// freopen("D:\\3022244240\\vscode\\txt\\in.txt", "r", stdin);
// freopen("D:\\3022244240\\vscode\\txt\\out.txt", "w", stdout);
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int T = 1;
// cin >> T;
while (T--) solve();
return 0;
}
/*
*/
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 4208kb
input:
3 1 0 1 1 1 2 2 1 2 2
output:
0 1.0000000000
result:
wrong answer 1st numbers differ - expected: '1.0000000', found: '0.0000000', error = '1.0000000'