QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#717448#9576. Ordainer of Inexorable Judgmentucup-team2179WA 0ms4364kbC++204.2kb2024-11-06 18:00:022024-11-06 18:00:02

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 18:00:02]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4364kb
  • [2024-11-06 18:00:02]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define pii pair<double, double>
#define ll long long
#define db long double
using namespace std;
const db eps = 1e-12;
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; }
    bool operator==(const Point& B) const {
        return sgn(x - B.x) == 0 && sgn(y - B.y) == 0;
    }
} 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)};
    }
}
db Dis_point_seg(Point P, Point A, Point B) {
    if (A == B)
        return len(P - A);
    Vector v1 = B - A, v2 = P - A, v3 = P - B;
    if (sgn(v1 * v2) < 0)
        return len(v2);
    if (sgn(v1 * v3) > 0)
        return len(v3);
    return abs((v1 ^ v2) / len(v1));
}
db cal(db t, db mn, db mx, db st) {
    if (sgn(st - mn) == -1 || sgn(st - mx) == 1) {
        db temm = mn - st;
        if (sgn(temm) == -1)
            temm += 2 * PI;
        db sheng = t - temm;
        if (sgn(sheng) == 1){
        db ans = floor(sheng / (2 * PI)) * (mx - mn);
        sheng -= floor(sheng / (2 * PI));
        ans += min(sheng, mx - mn);
        return ans;}
        else
            return 0;
    } else {
        db ans = min((db)t, mx - st);
        t -= ans;
        db temm = mn - mx;
        if (sgn(temm) == -1)
            temm += 2 * PI;
        if (sgn(t - temm) == 1) {
            db sheng = t - temm;
            ans += floor(sheng / (2 * PI)) * (mx - mn);
            sheng -= floor(sheng / (2 * PI));
            ans += min(sheng, mx - mn);
        }
        return ans;
    }
}
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});
    }
    for (int i = 0; i < n; i++) {
        db tem = Dis_point_seg({0, 0}, Points[i], Points[(i + 1) % n]);
        if (sgn(tem - d) != 1) {
            cout << fixed << setprecision(12) << t << "\n";
            return;
        }
    }
        Circle yuan;
    yuan.r = d;
    vector<db> vec;
    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);
        vec.push_back(tem1);
        vec.push_back(tem2);
    }
    db st = atan2(y0, x0);
    sort(vec.begin(), vec.end());
    pii tem = {0, 1};
    db mxdis = 0;
    for (int i = 0; i < vec.size(); i++) {
        int j = (i + 1) % (int)vec.size();
        if (abs(vec[j] - vec[i]) > mxdis) {
            mxdis = vec[j] - vec[i];
            tem = {vec[j], vec[i]};
        }
    }
    db ans;
    if (tem.first < tem.second) {
        ans = cal(t, tem.first, tem.second, st);
    } else {
        ans = cal(t, tem.first, 2 * PI, st) + cal(t, 0, tem.second, st);
    }
    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;
}

詳細信息

Test #1:

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

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

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

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

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

input:

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

output:

10001.886402906238

result:

wrong answer 1st numbers differ - expected: '2500.2406700', found: '10001.8864029', error = '3.0003695'