QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#717155#9576. Ordainer of Inexorable Judgmentucup-team2179#WA 1ms4332kbC++203.0kb2024-11-06 17:04:392024-11-06 17:04:39

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-06 17:04:39]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4332kb
  • [2024-11-06 17:04:39]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define pii pair<int, int>
#define ll long long
#define db double
using namespace std;
const db eps = 1e-7;
const db PI = acos(-1.0);
int sgn(db x) {
    if (fabs(x) < eps)
        return 0;
    return x > 0 ? 1 : -1;
}
typedef struct Point {
    db x, y;
    Point(db x = 0, db y = 0) : x(x), y(y){}
    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); }
    db operator^(const Point &B) const { return x * B.y - y * B.x; }
    db operator*(const Point &B) const { return x * B.x + y * B.y; }
} Vector;
db len(Vector A) {
    return sqrt(A * A);
}
Vector Rotate(Vector A, db b) {
    Vector B(sin(b), cos(b));
    return Vector(A ^ B, A * B);
}
struct Line {
    Point s, e;
    Line(){}
    Line(Point x, Point y) : s(x), e(y) {}
};
Vector devc(Line l) {
    return l.s - l.e;
}
struct Circle {
    Point c;
    db r;
    Circle(Point c = Point(), db r = 0) : c(c), r(r){}
};
db distance(Point p1, Point p2) {
    return sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y));
}
vector<Vector> get_tangents(Point p, Circle C) {
    Vector u = C.c - p;
    db dist = len(u);
    if (dist < C.r)
        return {};
    else if (sgn(dist - C.r) == 0)
        return {Rotate(u, PI / 2)};
    else {
        db ang = asin(C.r / dist);
        return {Rotate(u, -ang), Rotate(u, ang)};
    }
}
void solve() {
    int n, x0, y0, d;
    db t;
    cin >> n >> x0 >> y0 >> d >> t;
    vector<Point> Points;
    for (int i = 1; i <= n; i++) {
        int x, y;
        cin >> x >> y;
        Points.push_back({x, y});
    }
    Circle yuan;
    yuan.r = d;
    db mn = 2 * PI, mx = 0;
    for (int i = 1; i <= n; i++) {
        auto [x, y] = Points[i - 1];
        auto qie = get_tangents(Points[i - 1], yuan);
        db tem1 = atan2(-qie[0].y, -qie[0].x);
        db tem2 = atan2(-qie[1].y, -qie[1].x);
        if (tem1 > tem2)
            swap(tem1, tem2);
        mn = min(mn, tem1);
        mx = max(mx, tem2);
    }
    db st = atan2(y0, x0);
    if (st < mn || st > mx) {
        db temm = mn - st;
        if (temm < 0)
            temm += 2 * PI;
        db sheng = t - temm;
        db ans = floor(sheng / (2 * PI)) * (mx - mn);
        sheng -= floor(sheng / (2 * PI));
        ans += min(sheng, mx - mn);
        cout << fixed << setprecision(12) << ans << "\n";
    } else {
        db ans = min((db)t, mx - st);
        t -= ans;
        db temm = mn - mx;
        if (temm < 0)
            temm += 2 * PI;
        if (t > temm) {
            db sheng = t - temm;
            ans += floor(sheng / (2 * PI)) * (mx - mn);
            sheng -= floor(sheng / (2 * PI));
            ans += min(sheng, mx - mn);
        }
        cout << fixed << setprecision(12) << ans << "\n";
    }
}
signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 4292kb

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: 4304kb

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: 4264kb

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: 4316kb

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: 1ms
memory: 4332kb

input:

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

output:

10002.045610866504

result:

wrong answer 1st numbers differ - expected: '2500.2406700', found: '10002.0456109', error = '3.0004331'