QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#807882 | #9869. Horizon Scanning | ucup-team4975# | WA | 1ms | 4200kb | C++23 | 1.5kb | 2024-12-10 13:58:27 | 2024-12-10 13:58:28 |
Judging History
answer
#include <bits/stdc++.h>
#define fir first
#define sec second
#define el '\n'
#define debug(x) cout << #x << ":: " << x << endl;
#define FINISH cout << "FINISH" << endl;
#define debugv(x) cout << #x << ":: ";\
for (auto i : x) \
cout << i << " "; \
cout << endl
using namespace std;
using ll = long long;
using ld = long double;
using PII = pair<int, int>;
const int inf = 0x3f3f3f3f;
const int N = 200020;
const ld PI = 3.14159265358979323846;
struct point{
ll x, y;
ld ang;
};
ld getang(int x, int y) {
if (x == 0 || y == 0) {
if (x > 0 && y == 0) {
return 0.0;
}
else if (x == 0 && y > 0) {
return PI / 2;
}
else if (x < 0 && y == 0) {
return PI;
}
else {
return PI * 3 / 2;
}
}
if (y > 0) {
return atan(y / x);
}
else {
return PI + atan(y / x);
}
}
void solve()
{
int n, k;
cin >> n >> k;
vector<point> a(2 * n + 1);
for (int i = 1; i <= n; i++) {
cin >> a[i].x >> a[i].y;
a[i].ang = getang(a[i].x, a[i].y);
}
for (int i = 1; i <= n; i++) {
a[i + n].ang = a[i].ang + PI * 2;
}
sort(next(a.begin()), a.end(), [&] (point x, point y) {
return x.ang < y.ang;
});
ld ans = 0;
for (int i = 1; i <= n; i++) {
ld nxt = a[i + k].ang - a[i].ang;
ans = max(ans, nxt);
}
cout << fixed << setprecision(10) << ans << el;
}
int main()
{
ios:: sync_with_stdio("false");
cin.tie(nullptr);
cout.tie(nullptr);
int T= 1;
cin >> T;
while (T--) {
solve();
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 4200kb
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 6.2831853072 3.1415926536
result:
wrong answer 4th numbers differ - expected: '3.1415927', found: '6.2831853', error = '1.0000000'