QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#722334#9576. Ordainer of Inexorable JudgmentredWA 1ms4240kbC++202.8kb2024-11-07 18:39:132024-11-07 18: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 18:39:13]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4240kb
  • [2024-11-07 18:39:13]
  • 提交

answer

#include<bits/stdc++.h>
#define IOS std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
using namespace std;
#define INF 0x3f3f3f3f
#define endl '\n'
#define int long long
#define db long double
using pll = std::pair<int, int>;
const db phi = acos(-1.0);
struct P {
	db x, y;
	P() {}
	P(db _x, db _y) : x(_x), y(_y) {}
	P operator+(P p) { return {x + p.x, y + p.y}; }
	P operator-(P p) { return {x - p.x, y - p.y}; }
	P operator*(db d) { return {x * d, y * d}; }
	P operator/(db d) { return {x / d, y / d}; }
	db dot(P p) { return x * p.x + y * p.y; }
	db det(P p) { return x * p.y - y * p.x; }
	db distTo(P p) { return (*this-p).abs(); }
	db alpha() { return atan2(y, x); }
	db abs() { return sqrt(abs2());}
	db abs2() { return x * x + y * y; }
	P rot90() { return P(-y,x);}
	P unit() { return *this/abs(); }
	P rot(db an){ return {x*cos(an) - y*sin(an),x*sin(an) + y*cos(an)}; }
};
struct C
{
    P c;
    db r;
    P point(db a) {return P(c.x + cos(a) * r, c.y + sin(a) * r);}
};
void tp(P p, P o, db r, P& p1, P& p2) {
    db line = p.distTo(o);
    db ang = acos(r / line);
    P u, l;
    l = p - o;
    u.x = l.x / l.abs() * r;
    u.y = l.y / l.abs() * r;
    p1 = u.rot(-ang);
    p2 = u.rot(ang);
    p1 = p1 + o;
    p2 = p2 + o;
}
void solv(){
    int n;
    db d, t;
    C o;
    db x0, y0;
    cin >> n >> x0 >> y0 >> o.r >> t;
    o.c.x = o.c.y = 0;
    vector<P> e1,e2;
    for (int i = 1;i <= n;i++) {
        P t;
        cin >> t.x >> t.y;
        P p1, p2;
        tp(t, o.c, o.r, p1, p2);
        e2.push_back((t-p1)/(t-p1).abs());
        e1.push_back((t-p2)/(t-p2).abs2());
    }
    db tmp=-1;
    P ii, jj;
    for (P i : e1) {
        for (P j : e2) {
            db num = i.dot(j);
            if (tmp == -1) tmp = num, ii = i, jj = j;
            else if (tmp > num) tmp = num, ii = i, jj = j;
        }
    }
    db ans = 0;
    //cout << ii.x << " " << ii.y << endl;
    //cout << jj.x << " " << jj.y << endl;
    while (t >= 2.0 * phi) {
        t -= 2.0 * phi;
        ans = ans + acos(ii.dot(jj));
    }
    db a = ii.alpha(), b = jj.alpha();
    //cout << a << " " << b << endl;
    if (a > b) b = b + 2.0 * phi;
    //cout << a << " " << b << endl;
    // if (a > b) swap(a, b);
    db x = P(x0, y0).alpha();
    db y = y + t;
    ans = ans + max(min(y, b) - max(a, x), (db)0.0);
    a = a + 2.0 * phi;
    b = b + 2.0 * phi;
    ans = ans + max(min(y, b) - max(a, x), (db)0.0);
    a = a - 4.0 * phi;
    b = b - 4.0 * phi;
    ans = ans + max(min(y, b) - max(a, x), (db)0.0);
    cout << fixed << setprecision(16) << ans << endl;


}


signed main(){
//#ifdef LOCAL
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
//#endif
    IOS;
    int T=1;
    //cin >> T;
    while (T--){
        solv();
    }
    return 0;
}

详细

Test #1:

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

input:

3 1 0 1 1
1 2
2 1
2 2

output:

1.0000000000000000

result:

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

Test #2:

score: 0
Accepted
time: 1ms
memory: 4208kb

input:

3 1 0 1 2
1 2
2 1
2 2

output:

1.5707963267948966

result:

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

Test #3:

score: 0
Accepted
time: 1ms
memory: 4176kb

input:

3 1 0 1 10000
1 2
2 1
2 2

output:

2500.7077522574754294

result:

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

Test #4:

score: -100
Wrong Answer
time: 1ms
memory: 4172kb

input:

3 10000 10000 1 10000
10000 9999
10000 10000
9999 10000

output:

2499.0245759601938371

result:

wrong answer 1st numbers differ - expected: '0.3842413', found: '2499.0245760', error = '2498.6403347'