QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#788185#9668. Isoball: 2D VersionTJ_Andeviking#WA 4ms3704kbC++202.7kb2024-11-27 16:08:432024-11-27 16:08:43

Judging History

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

  • [2024-11-27 16:08:43]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3704kb
  • [2024-11-27 16:08:43]
  • 提交

answer

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

using ll = long long;
using pii = pair<int, int>;
#define range(x) (x).begin(), (x).end()

struct Point {
    ll x, y;
    Point() {};
    Point(ll x, ll y)
        : x(x), y(y)
    {
    }
    Point operator-(Point B)
    {
        return Point(x - B.x, y - B.y);
    }
};

ll Cross(Point a, Point b)
{
    return a.x * b.y - a.y * b.x;
}
int sgn(ll x)
{
    if (x < 0)
        return -1;
    else if (x == 0)
        return 0;
    else
        return 1;
}

ll Dot(Point a, Point b)
{
    return a.x * b.x + a.y * b.y;
}
bool Cross_segment(Point a, Point b, Point c, Point d)
{
    // cout << c.x << ' ' << c.y << ' ' << d.x << ' ' << d.y << '\n';
    ll c1 = Cross(b - a, c - a), c2 = Cross(b - a, d - a);
    ll d1 = Cross(d - c, a - c), d2 = Cross(d - c, b - c);
    bool flag = sgn(c1) * sgn(c2) <= 0 && sgn(d1) * sgn(d2) <= 0;
    if (!flag)
        return false;
    if (Cross(b - a, c - d) == 0) {
        if (a.x > b.x)
            swap(a, b);
        if (c.x >= a.x && c.x <= b.x)
            return true;
        if (d.x >= a.x && d.x <= b.x)
            return true;
        if (c.x > d.x)
            swap(c, d);
        swap(a, c), swap(b, d);
        if (c.x >= a.x && c.x <= b.x)
            return true;
        if (d.x >= a.x && d.x <= b.x)
            return true;
        return false;
    }
    return true;
}

void solve()
{
    int x, y, r, vx, vy;
    cin >> x >> y >> r >> vx >> vy;

    int lx, ly, rx, ry;
    cin >> lx >> ly >> rx >> ry;

    lx += r, ly += r;
    rx -= r, ry -= r;
    if (rx < lx || ry < ly) {
        cout << "No\n";
        return;
    }

    Point a(x, y);
    ll cnt = 0;
    if (vx && vy)
        cnt = min(10000000 / abs(vx), 10000000 / abs(vy));
    else if (vx)
        cnt = 10000000 / abs(vx);
    else
        cnt = 10000000 / abs(vy);
    x += cnt * vx;
    y += cnt * vy;
    Point b(x, y);

    // cout << a.x << ' ' << a.y << ' ' << b.x << ' ' << b.y << '\n';

    Point cka(lx, ly), ckb(lx, ry);

    if (Cross_segment(a, b, cka, ckb)) {
        cout << "Yes\n";
        return;
    }
    ckb.x = rx, ckb.y = ly;
    if (Cross_segment(a, b, cka, ckb)) {
        cout << "Yes\n";
        return;
    }
    ckb.x = rx, ckb.y = ry;
    cka.x = lx, cka.y = ry;
    if (Cross_segment(a, b, cka, ckb)) {
        cout << "Yes\n";
        return;
    }
    cka.x = rx, cka.y = ly;
    if (Cross_segment(a, b, cka, ckb)) {
        cout << "Yes\n";
        return;
    }

    cout << "No\n";
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    cin >> t;
    while (t--)
        solve();
    return 0;
}

詳細信息

Test #1:

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

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

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: 4ms
memory: 3628kb

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 371st lines differ - expected: 'No', found: 'Yes'