QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#880743#3854. RadarychangseokWA 4ms4352kbC++172.9kb2025-02-03 19:21:392025-02-03 19:21:40

Judging History

This is the latest submission verdict.

  • [2025-02-03 19:21:40]
  • Judged
  • Verdict: WA
  • Time: 4ms
  • Memory: 4352kb
  • [2025-02-03 19:21:39]
  • Submitted

answer

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;
typedef long long ll;
typedef long double lb;
#define all(v) v.begin(), v.end()
#define M_PI 3.14159265358979323846


lb getdist(ll x, ll y, ll r, lb a){
    // cout << r * cos(a) << ' ' << r * sin(a) << ' ';

    lb dx = x - r * cos(a);
    lb dy = y - r * sin(a);

    return dx*dx + dy*dy;
}

ll n, m, q;
ll x, y, r;

vector<ll> vr;
vector<lb> angle;

int main(){
    cin.tie(0)->sync_with_stdio(0);
    cout << fixed;
    cout.precision(12);

    cin >> n >> m >> q;
    
    for (int i = 1; i <= n; i++){
        cin >> r;
        vr.push_back(r);
    }
    for (int i = 1; i <= m; i++){
        cin >> x >> y;
        angle.push_back(atan2(y,x));
    }

    sort(all(vr));
    sort(all(angle));

    vector<lb> tmp;
    for (int i = 0; i < m; i++){
        tmp.push_back(angle[i] - 2*M_PI);
    }
    for (int i = 0; i < m; i++){
        tmp.push_back(angle[i]);
    }
    for (int i = 0; i < m; i++){
        tmp.push_back(angle[i] + 2*M_PI);
    }

    // for (int i = 0; i < n; i++){
    //     cout << vr[i] << ' ';
    // }
    // cout << endl;
    // for (int i = 0; i < m; i++){
    //     cout << angle[i] * 180 / M_PI << endl;

    //     // if (i % m == m-1) cout << endl;
    // }
    // cout << endl;
    // for (int i = 0; i < 3*m; i++){
    //     cout << tmp[i] * 180 / M_PI << endl;

    //     if (i % m == m-1) cout << endl;
    // }
    // cout << endl;
    // cout << endl;

    while (q--){
        cin >> x >> y;

        int left = 0;
        int right = n - 1;

        while (left < right){
            int mid = (left + right + 1) / 2;

            if (x*x+y*y >= vr[mid]*vr[mid]){
                left = mid;
            }else{
                right = mid - 1;
            }
        }

        // cout << x << ' ' << y << ' ' << vr[left] << '\n';

        int lr = left;
        lb theta = atan2(y, x);

        int lt = 0;

        left = 0;
        right = 3*m - 1;

        while (left < right){
            int mid = (left + right + 1) / 2;

            if (tmp[mid] > theta) right = mid - 1;
            else left = mid;
        }

        // cout << angle[left].deg << ' ' << theta << ' ' << angle[right].deg << endl;

        lt = left;
        
        // cout << lt << ' ' << rt << endl;

        lb dist = 9e18;

        for (int ridx = lr; ridx <= lr+1; ridx++){
            if (ridx < 0) continue;
            if (ridx >= n) continue;

            for (int tidx = lt-3; tidx <= lt+3; tidx++){
                if (tidx < 0) continue;

                lb d = getdist(x, y, vr[ridx], angle[(tidx)%m]);
                // cout << d << endl;

                dist = min(dist, d);
            }
        }

        cout << sqrt(dist) << '\n';
        // cout << endl;
    }

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 8 4
2
4
7
1 0
2 1
0 1
-1 1
-5 -2
-5 -6
-2 -7
6 -1
-1 -1
3 1
-5 -3
8 1

output:

0.605291072917
0.977772290466
1.551845105402
1.414213562373

result:

ok 4 numbers

Test #2:

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

input:

1 8 32
7
0 1
1 0
0 -1
-1 0
1 -1
-1 1
-1 -1
1 1
20 10
10 20
-20 10
10 -20
-10 20
20 -10
-10 -20
-20 -10
2 1
1 2
-2 1
1 -2
-1 2
2 -1
-1 -2
-2 -1
5 0
0 5
-5 0
0 -5
5 5
5 -5
-5 5
-5 -5
9 0
0 9
-9 0
0 -9
9 9
9 -9
-9 9
-9 -9

output:

15.874985099258
15.874985099258
15.874985099258
15.874985099258
15.874985099258
15.874985099258
15.874985099258
15.874985099258
4.929656701046
4.929656701046
4.929656701046
4.929656701046
4.929656701046
4.929656701046
4.929656701046
4.929656701046
2.000000000000
2.000000000000
2.000000000000
2.00000...

result:

ok 32 numbers

Test #3:

score: 0
Accepted
time: 4ms
memory: 4352kb

input:

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

output:

9.055385138137
4.123105625618
3.605551275464
11.045361017187
15.297058540778
1.414213562373
8.246211251235
7.000000000000
8.944271909999
3.000000000000
12.165525060596
5.000000000000
5.099019513593
11.180339887499
1.414213562373
2.000000000000
2.000000000000
3.000000000000
3.162277660168
8.246211251...

result:

ok 1681 numbers

Test #4:

score: -100
Wrong Answer
time: 3ms
memory: 4352kb

input:

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

output:

11.777372119304
4.631593682590
6.895656100977
12.291422905367
6.555964003581
4.270304206047
4.392536000448
6.367825885745
6.555964003581
2.990316379371
10.187520359495
2.833626166509
2.977064831365
4.696779860162
4.352239888693
11.328455809797
3.384030147710
1.836459365744
2.947251516416
7.635131895...

result:

wrong answer 356th numbers differ - expected: '5.8945030', found: '6.1229349', error = '0.0387534'