QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#811192#9869. Horizon ScanningZycK#WA 19ms3872kbC++201.9kb2024-12-12 16:19:112024-12-12 16:19:18

Judging History

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

  • [2024-12-12 16:19:18]
  • 评测
  • 测评结果:WA
  • 用时:19ms
  • 内存:3872kb
  • [2024-12-12 16:19:11]
  • 提交

answer

#include <bits/stdc++.h>
#define double long double
#define For(i, l, r) for (int i=l; i<=r; ++i)
using namespace std;
template <typename T>
inline void read(T &x) {
    char c = getchar(); int w = 1; x = 0;
    while (!isdigit(c))
        (c == '-') && (w = -w), c = getchar();
    while (isdigit(c))
        x = x * 10 + (c ^ '0'), c = getchar();
    x *= w;
}

void test()
{
    double x = 1, y = 1e9;
    double res = atan(y / x);
    printf("%.10Lf\n", res);
}

const double Pi = acos(-1.0);
const int N = 200010;
int T, n, k;
double x, y, a[N];
signed main() {
    // test();
    read(T);
    while (T -- > 0) {
        read(n); read(k);
        For(i, 1, n) {
            read(x); read(y);
            if (!x) {
                if (y > 0) a[i] = Pi/2.0;
                else a[i] = Pi*3.0/2;
                continue;
            }
            if (!y) {
                if (x < 0) a[i] = Pi;
                else a[i] = 0;
                continue;
            }

            // printf("%.10lf %.10lf\n", x, y);

            double Ang = atan(y / x);
            if (Ang < 0) Ang += Pi;
            if (y < 0) {
                Ang += Pi;
            }
            a[i] = Ang;
            // printf("%.10lf\n", a[i]);
        }
        std :: sort(a + 1, a + n + 1);
        double Ans = 0;
        if (n == k) {
            Ans = 2 * Pi;
        }
        for (int i=1; i<=n; ++i) {
            double Now = a[(i+k-1)%n+1] - a[i];
            if (Now < 0) Now += 2 * Pi;
            Ans = max(Ans, Now);
        }
        printf("%.10Lf\n", Ans);
    }
    return 0;
}
/*
5
1 1
0 1

8 2
1 0
1 1
0 1
-1 1
-1 0
-1 -1
0 -1
1 -1

4 2
-1 1
0 1
0 2
1 1

4 2
-1000000000 0
-998244353 1
998244353 1
1000000000 0

3 1
0 1
0 2
0 -1

1
2 1
-1 -1
1 -1

1
6 1
1000000000 -1
-1000000000 1
-1000000000 -1
1000000000 1
1 1000000000
-1 1000000000
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
1 1
0 1
8 2
1 0
1 1
0 1
-1 1
-1 0
-1 -1
0 -1
1 -1
4 2
-1 1
0 1
0 2
1 1
4 2
-1000000000 0
-998244353 1
998244353 1
1000000000 0
3 1
0 1
0 2
0 -1

output:

6.2831853072
1.5707963268
5.4977871438
3.1415926546
3.1415926536

result:

ok 5 numbers

Test #2:

score: -100
Wrong Answer
time: 19ms
memory: 3788kb

input:

10000
16 1
-10 -6
-5 -6
-4 9
-2 5
-2 10
1 -7
1 -5
1 6
3 1
4 -9
6 -10
6 -3
6 1
8 -5
8 -4
9 -4
17 4
-9 2
-8 -4
-8 -3
-8 -1
-6 -2
-6 -1
-6 8
-5 -8
-5 10
-4 8
-2 -8
4 -9
4 0
5 -3
8 -5
9 -2
10 10
10 6
-7 2
-4 6
-2 -7
-2 -1
-1 7
1 -9
1 8
3 -4
7 -4
9 -2
14 3
-9 10
-8 -10
-8 -8
-6 -7
-6 -5
-1 -7
-1 -2
0 -1
...

output:

1.6929914975
2.5748634361
4.6527582673
2.7726331074
5.7427658069
4.8576989910
3.4198923126
2.8127999621
6.2831853072
6.2831853072
5.1172807667
6.1467827028
3.8420890235
2.3424967168
3.4633432080
6.2831853072
5.9614347528
3.3247034709
5.2627749281
5.6724593428
1.6738779353
1.1141908549
2.4087775518
6...

result:

wrong answer 42nd numbers differ - expected: '6.2831853', found: '6.2599337', error = '0.0037006'