QOJ.ac

QOJ

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

Judging History

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

  • [2024-12-11 00:17:12]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3812kb
  • [2024-12-11 00:17:11]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define double long double
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; i < n; ++ i)
    {
        double x,y;
        cin >> x >> y;
        if(y == 0)
        {
            if(y > 0) p.push_back(0);
            else p.push_back(pi);
            continue;
        }
        if(x == 0)
        {
            if(x > 0) p.push_back(pi/2.);
            else p.push_back(pi*3./2.);
            continue;
        }
        double a = atan(fabs(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: 0
Wrong Answer
time: 1ms
memory: 3812kb

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
3.1415926536
3.9269908170
6.2831853062
6.2831853072

result:

wrong answer 2nd numbers differ - expected: '1.5707963', found: '3.1415927', error = '1.0000000'