QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#808712 | #9869. Horizon Scanning | H_ZzZ | WA | 1ms | 3812kb | C++23 | 1.2kb | 2024-12-11 00:17:11 | 2024-12-11 00:17:12 |
Judging History
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();
}
Details
Tip: Click on the bar to expand more detailed information
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'