QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#807919#9869. Horizon ScanningREN_RENWA 23ms4212kbC++201.3kb2024-12-10 14:41:152024-12-10 14:41:25

Judging History

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

  • [2024-12-10 14:41:25]
  • 评测
  • 测评结果:WA
  • 用时:23ms
  • 内存:4212kb
  • [2024-12-10 14:41:15]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define db long double
using namespace std;
int n, k;
const db pi = 3.14159265358979323846;
void solve() {
    cin >> n >> k;
    vector<db> aa;
    for(int i = 1, x, y; i <= n; i ++) {
        cin >> x >> y;
        if(y == 0) {
            if(x > 0)
                aa.push_back(0);
            else
                aa.push_back(pi);
        } else if(x == 0) {
            if(y > 0) {
                aa.push_back(pi / 2);
            } else {
                aa.push_back(pi * 3 / 2);
            }
        } else {
            if(x < 0 && y < 0) aa.push_back(atan(y/x) + pi);
            else if(x < 0 && y > 0) aa.push_back(atan(y/x) + pi);
            else if(x > 0 && y < 0) aa.push_back(atan(y / x) + pi * 2);
            else aa.push_back(atan(y / x));
        }
    }
    db ans = 0;
    sort(aa.begin(), aa.end());
    for(int i = 0; i < n; i ++) {
        int h = i + k;
        if(h < n) {
            ans = max(ans, aa[h] - aa[i]);
        } else {
            ans = max(ans, aa[h % n] - aa[i] + 2 * pi);
        }
    }
    cout << fixed << setprecision(10) << ans << '\n';
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int _ = 1;
    cin >> _;
    while(_ --) solve();
    return 0;
}

詳細信息

Test #1:

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

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

result:

ok 5 numbers

Test #2:

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

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.4056476494
3.1415926536
4.5880339858
2.5535900500
6.2831853072
5.4977871438
3.4633432080
3.1415926536
6.2831853072
6.2831853072
5.4977871438
6.2831853072
4.0688878716
3.1415926536
3.9269908170
6.2831853072
6.2831853072
3.4078447027
5.4977871438
5.4977871438
2.3561944902
1.2490457724
3.1415926536
6...

result:

wrong answer 1st numbers differ - expected: '1.6929915', found: '1.4056476', error = '0.1697255'