QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#818242#9668. Isoball: 2D VersionccsurzwWA 9ms3732kbC++232.5kb2024-12-17 17:53:262024-12-17 17:53:28

Judging History

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

  • [2024-12-17 17:53:28]
  • 评测
  • 测评结果:WA
  • 用时:9ms
  • 内存:3732kb
  • [2024-12-17 17:53:26]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
#define double ld
#define N 201000
#define endl '\n'
ll mod = 998244353;
ld x, y, r, Vx, Vy,nx,ny;
ld Lx, Ly, Rx, Ry;
ld k, b;
ld get_y(ld x) {
    return k * x + b;
}
ld get_x(ld y) {
    return (y - b) / k;
}
struct Point {
    ld x;
    ld y;
};
bool isOnRay(Point p, Point rayStart, Point rayDirection) {
    Point vecToPoint = { p.x - rayStart.x, p.y - rayStart.y };

    double crossProduct = vecToPoint.x * rayDirection.y - vecToPoint.y * rayDirection.x;
    const double eps = 1e-9;  
    if (std::fabs(crossProduct) > eps) {
        return false;
    }

    // 计算点乘判断方向,若点乘大于等于0,表示点在射线的延伸方向上(相对于起点)
    double dotProduct = vecToPoint.x * rayDirection.x + vecToPoint.y * rayDirection.y;
    return dotProduct >= 0;
}
void solve() {
    cin >> x >> y >> r >> Vx >> Vy;
    cin >> Lx >> Ly >> Rx >> Ry;
    
    Point p, start, ray;
    start.x = x;
    start.y = y;
    ray.x = Vx;
    ray.y = Vy;
    k = Vy / Vx;//移动方向方程的k
    b = y - k * x;//b
    
    //将矩形左边的顶点加r
    nx = Lx + r;//新的圆坐标
    ny = get_y(nx);//新的圆坐标
    p.x = nx;
    p.y = ny;
    if (ny - Ly >= r && Ry - ny >= r && Rx - nx >= r) {
        if (isOnRay(p ,start,ray )) {//判断是移动方向是否正确
            cout << "Yes" << endl;
            return;
        }
    }
    
    nx = Rx - r;//新的圆坐标
    ny = get_y(nx);//新的圆坐标
    p.x = nx;
    p.y = ny;
    if (ny - Ly >= r && Ry - ny >= r && nx - Lx >= r) {
        if (isOnRay(p, start, ray)) {//判断是移动方向是否正确
            cout << "Yes" << endl;
            return;
        }
    }

    ny = Ly + r;
    nx = get_x(ny);
    p.x = nx;
    p.y = ny;
    if (nx - Lx >= r && Ry - ny >= r && Rx - nx >= r) {
        if (isOnRay(p, start, ray)) {//判断是移动方向是否正确
            cout << "Yes" << endl;
            return;
        }
    }

    ny = Ry - r;
    nx = get_x(ny);
    p.x = nx;
    p.y = ny;
    if (nx - Lx >= r && ny - Ly >= r && Rx - nx >= r) {
        if (isOnRay(p, start, ray)) {//判断是移动方向是否正确
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
0 0 1 1 0
2 -2 6 2
0 0 1 1 0
2 0 6 2
0 0 1 1 1
1 1 3 3
0 0 1 -1 -1
1 1 3 3
0 0 1 -1 1
-5 -5 5 5

output:

Yes
No
Yes
No
Yes

result:

ok 5 lines

Test #2:

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

input:

2
0 0 1000000 1000000 1000000
-1000000 -1000000 1000000 1000000
1000000 1000000 1 -1000000 -1000000
-1000000 -1000000 -999999 -999999

output:

Yes
No

result:

ok 2 lines

Test #3:

score: -100
Wrong Answer
time: 9ms
memory: 3648kb

input:

10000
10 -10 10 1 -2
-13 -8 6 -1
-7 -10 3 3 1
-3 -12 14 -9
-9 -2 4 4 -3
-11 7 -8 12
-3 1 8 -1 0
-11 1 19 13
-1 8 9 -3 2
11 -5 17 4
-2 -7 3 -3 5
-12 -14 10 1
0 3 6 -5 3
-11 2 2 16
4 9 6 5 -4
-8 -11 18 -1
0 0 8 4 -2
-10 -15 1 12
8 4 4 5 2
-17 3 8 7
-3 7 10 -4 0
1 0 10 20
-6 -10 5 -3 -1
-20 -20 15 7
5 ...

output:

No
No
No
No
No
Yes
No
No
No
No
No
Yes
No
Yes
No
No
Yes
No
Yes
No
No
No
No
No
Yes
No
No
No
Yes
No
No
No
Yes
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
Yes
Yes
No
No
Yes
Yes
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes...

result:

wrong answer 161st lines differ - expected: 'Yes', found: 'No'