QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#859197#9668. Isoball: 2D Versionshiyahahaya#WA 0ms4096kbC++204.3kb2025-01-17 16:20:012025-01-17 16:20:02

Judging History

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

  • [2025-01-17 16:20:02]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4096kb
  • [2025-01-17 16:20:01]
  • 提交

answer

#include <iostream>
#include <math.h>
#include <numbers>

using namespace std;

double PI = std::numbers::pi;

double xo, yo, r, vx, vy, ix1, iy1, ix2, iy2;

struct place
{
    double px;
    double py;
};

double trans(place O, place A)
{
    //cout << "A: " << A.px << " " << A.py << endl;
    double tana = (A.py - O.py) / (A.px - O.px);
    if (A.px >= 0 && A.py >= 0)
    {
        return atan(tana);
    }
    else if (A.px < 0 && A.py <= 0)
    {
        return PI + atan(tana);
    }
    else if (A.px <= 0 && A.py >= 0)
    {
        return PI + atan(tana);
    }
    else if (A.px >= 0 && A.py <= 0)
    {
        return 2 * PI + atan(tana);
    }
    return atan(tana);
}

int main()
{
    long int n;
    cin >> n;
    while (n--)
    {
        cin >> xo >> yo >> r >> vx >> vy >> ix1 >> iy1 >> ix2 >> iy2;
        swap(iy1, iy2);

        // cout << ix1 << " " << iy1 << " " << ix2 << " " << iy2 << endl;

        if (abs(ix1 - ix2) < 2 * r || abs(iy1 - iy2) < 2 * r)
        {
            cout << "NO" << endl;
            continue;
        }

        double L      = pow(vx * vx + vy * vy, 0.5);
        place  leftp  = {xo, yo};
        place  rightp = {xo + 3000000 * vx / L, yo + 3000000 * vy / L};

        double t = trans(leftp, rightp) / PI;/*
        cout << ix1 + r << " ... " << iy1 - r << endl;
        cout << ix1 + r << " ... " << iy2 + r << endl;
        cout << ix2 - r << " ... " << iy1 - r << endl;
        cout << ix2 - r << " ... " << iy2 + r << endl;*/
        double a = trans(leftp, {ix1 + r, iy1 - r}) / PI;
        double b = trans(leftp, {ix1 + r, iy2 + r}) / PI;
        double c = trans(leftp, {ix2 - r, iy1 - r}) / PI;
        double d = trans(leftp, {ix2 - r, iy2 + r}) / PI;
/*
        cout << t << " * PI" << endl;
        cout << a << " * PI" << endl;
        cout << b << " * PI" << endl;
        cout << c << " * PI" << endl;
        cout << d << " * PI" << endl;
*/
        if (xo < ix1 + r)
        {
            if (yo > iy1 - r)
            {
                //cout << 1 << endl;
                if ((t >= 0 && t < b) || (t <= 2 && t > c))
                {
                    cout << "NO" << endl;
                    continue;
                }
            }
            else if (yo < iy2 + r)
            {
                //cout << 2 << endl;
                if ((t > a && t <= 2) || (t < d && t >= 0))
                {
                    cout << "NO" << endl;
                    continue;
                }
            }
            else
            {
                //cout << 3 << endl;
                if (t > a && t < b)
                {
                    cout << "NO" << endl;
                    continue;
                }
            }
        }
        else if (xo > ix2 - r)
        {
            if (yo > iy1 - r)
            {
                //cout << 4 << endl;
                if ((t > d && t <= 2) || (t < a && t >= 0))
                {
                    cout << "NO" << endl;
                    continue;
                }
            }
            else if (yo < iy2 + r)
            {
                //cout << 5 << endl;
                if ((t > b && t <= 2) || (t < c && t >= 0))
                {
                    cout << "NO" << endl;
                    continue;
                }
            }
            else
            {
                //cout << 6 << endl;
                if ((t > d && t <= 2) || (t < c && t >= 0))
                {
                    cout << "NO" << endl;
                    continue;
                }
            }
        }
        else
        {
            if (yo > iy1 - r)
            {
                //cout << 7 << endl;
                if ((t > c && t <= 2) || (t < a && t >= 0))
                {
                    cout << "NO" << endl;
                    continue;
                }
            }
            else if (yo < iy2 + r)
            {
                //cout << 8 << endl;
                if ((t > b && t <= 2) || (t < d && t >= 0))
                {
                    cout << "NO" << endl;
                    continue;
                }
            }/*
            else
            {
                //cout << 9 << endl;
            }*/
        }

        cout << "YES" << endl;
    }
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 4096kb

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:

wrong answer 1st lines differ - expected: 'Yes', found: 'YES'