QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#808690#9869. Horizon ScanningH_ZzZWA 23ms4228kbC++231.2kb2024-12-11 00:02:112024-12-11 00:02:12

Judging History

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

  • [2024-12-11 00:02:12]
  • 评测
  • 测评结果:WA
  • 用时:23ms
  • 内存:4228kb
  • [2024-12-11 00:02:11]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
const double pi = 3.14159265358979;

using namespace  std;

void solve()
{
    int n,k;
    cin >> n >> k;
    vector<double>p;
    double one = 1.0;
    for(int i = 0, x, y; i < n; ++ i)
    {
        cin >> x >> y;
        if(x == 0)
        {
            if(y > 0) p.push_back(0);
            else p.push_back(pi);
            continue;
        }
        if(y == 0)
        {
            if(x > 0) p.push_back(pi/2);
            else p.push_back(pi*3/2);
            continue;
        }
        double a = atan(abs(one * y / x));
        if(x > 0 && y > 0)p.push_back(a);
        if(x > 0 && y < 0)p.push_back(2*pi-a);
        if(x < 0 && y > 0)p.push_back(pi-a);
        if(x < 0 && y < 0) p.push_back(pi+a);
    }
    sort(p.begin(),p.end());
    double ans = 0.0;
    for(int i = 0; i < n; ++ i)
    {
        if(i + k < n) ans = max(ans, p[i+k] - p[i]);
        else ans = max(ans, p[i+k-n] + 2*pi-p[i]);
    }
    cout << fixed << setprecision(10) << ans << '\n';
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    int _;
    cin >> _;
    while(_--)solve();
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 4228kb

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.1415926556
3.1415926536

result:

ok 5 numbers

Test #2:

score: -100
Wrong Answer
time: 23ms
memory: 4204kb

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.5415424402
5.3558900892
4.6314848812
3.7786629829
2.8127999621
6.2831853072
6.2831853072
5.1172807667
6.1588303126
3.8420890235
2.2318394956
3.4633432080
6.2831853072
5.5745590351
3.6528233659
5.4977871438
5.5532856490
1.4940244355
1.1141908549
2.8890383778
6...

result:

wrong answer 4th numbers differ - expected: '2.7726331', found: '2.5415424', error = '0.0833470'