QOJ.ac

QOJ

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

Judging History

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

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

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() {
        double l = len();
        return Point(x/l, y/l);
    }
    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();
    return make_pair(u.rotate(d).ext(l), u.rotate(-d).ext(l));
};

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);

    double PI = M_PIf64;
    double 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 <= PI) {
            tg_d0 = pts[i].ang;
            tg_d1 = pts.back().ang;
            break;
        }
        pts[i].ang += 2 * PI;
        pts.push_back(pts[i]);
    }


    double res = 0;
    int ncyc = floor(t / (2 * PI));
    res += ncyc * (tg_d1 - tg_d0);
    t -= ncyc * (2 * 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 * PI, nv_d1 + 2 * PI);
    cout << res << '\n';
} 

详细

Test #1:

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

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

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

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

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

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: 0
Accepted
time: 0ms
memory: 4300kb

input:

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

output:

4999.21911540874225

result:

ok found '4999.2191154', expected '4999.2191154', error '0.0000000'

Test #7:

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

input:

4 1 0 1 10000
-2 3300
-4 10000
-4 -10000
-2 -3300

output:

4999.20039185481528

result:

ok found '4999.2003919', expected '4999.2003919', error '0.0000000'

Test #8:

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

input:

4 -3040 2716 2147 2
-9033 -8520
-8999 -8533
-8988 -8511
-9004 -8495

output:

0

result:

wrong answer 1st numbers differ - expected: '0.3508301', found: '0.0000000', error = '0.3508301'