QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#799059#9576. Ordainer of Inexorable JudgmentfosovWA 1ms4352kbC++172.2kb2024-12-04 21:19:112024-12-04 21:19:12

Judging History

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

  • [2024-12-23 14:23:26]
  • hack成功,自动添加数据
  • (/hack/1303)
  • [2024-12-06 11:32:56]
  • hack成功,自动添加数据
  • (/hack/1271)
  • [2024-12-04 21:19:12]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4352kb
  • [2024-12-04 21:19:11]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

struct Point {
    double x, y, ang;
    Point() {};
    Point(double x, double y): x(x), y(y), ang(atan2(y, x)) {};

    Point operator+(Point p) {
        return Point(x+p.x, y+p.y);
    }
    Point operator-(Point p) {
        return Point(x-p.x, y-p.y);
    }
    double operator*(Point p) {
        return x*p.y-y*p.x;
    }
    bool operator<(Point p) {
        return ang < p.ang;
    }
    double len() {
        return sqrt(x*x+y*y);
    }
    Point unit() {
        return Point(x/len(), y/len());
    }
    Point ext(double l) {
        return Point(x*l, y*l);
    }
    Point rotate(double deg) {
        return Point(cos(deg)*x+sin(deg)*y, -sin(deg)*x+cos(deg)*y);
    }
};

pair<Point, Point> tangents(Point p, Point c, double r) {
    double s = (c-p).len();
    double l = sqrt(s*s-r*r);
    double d = atan2(r, l);
    Point u = (c-p).unit().ext(l);
    return make_pair(u.rotate(d), u.rotate(-d));
};

double intersect(double l0, double r0, double l1, double r1) {
    return max(0.0, min(r0, r1) - max(l0, l1)); 
}

int main() {
#ifdef TEST
    freopen("zz.in", "r+", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << setprecision(18);

    int n, x0, y0, d, t; cin >> n >> x0 >> y0 >> d >> t;

    vector<Point> pts;
    for (int i = 0; i < n; ++ i) {
        int x, y; cin >> x >> y;
        auto [p0, p1] = tangents(Point(0, 0), Point(x, y), d);
        pts.push_back(p0), pts.push_back(p1);
    }

    double tg_d0, tg_d1;
    sort(pts.begin(), pts.end());
    for (int i = 0; i < pts.size(); ++ i) {
        if (pts.back().ang - pts[i].ang < M_PI) {
            tg_d0 = pts[i].ang;
            tg_d1 = pts.back().ang;
            break;
        }
        pts[i].ang += 2 * M_PI;
        pts.push_back(pts[i]);
    }

    double res = 0;
    int ncyc = t / (2 * M_PI);
    res += ncyc * (tg_d1 - tg_d0), t -= ncyc * 2 * M_PI;
    
    double nv_d0 = Point(x0, y0).ang;
    double nv_d1 = nv_d0 + t;
    res += intersect(tg_d0, tg_d1, nv_d0, nv_d1);
    res += intersect(tg_d0, tg_d1, nv_d0 + 2 * M_PI, nv_d1 + 2 * M_PI);

    cout << res << '\n';
} 

詳細信息

Test #1:

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

input:

3 1 0 1 1
1 2
2 1
2 2

output:

1

result:

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

Test #2:

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

input:

3 1 0 1 2
1 2
2 1
2 2

output:

1.57079632679489656

result:

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

Test #3:

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

input:

3 1 0 1 10000
1 2
2 1
2 2

output:

2500.70775225747548

result:

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

Test #4:

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

input:

3 10000 10000 1 10000
10000 9999
10000 10000
9999 10000

output:

0.38424130029003456

result:

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

Test #5:

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

input:

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

output:

2500.2406700096094

result:

ok found '2500.2406700', expected '2500.2406700', error '0.0000000'

Test #6:

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

input:

4 1 0 1 10000
-2 3400
-4 10000
-4 -10000
-2 -3400

output:

4998.76693913146391

result:

wrong answer 1st numbers differ - expected: '4999.2191154', found: '4998.7669391', error = '0.0000904'