QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#808710 | #9869. Horizon Scanning | H_ZzZ | Compile Error | / | / | C++23 | 1.2kb | 2024-12-11 00:15:20 | 2024-12-11 00:15:28 |
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(x > 0)
p.push_back(0);
else
p.push_back(pi);
} else if(x == 0) {
if(y > 0) {
p.push_back(pi / 2);
} else {
p.push_back(pi * 3 / 2);
}
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();
}
详细
answer.code: In function ‘void solve()’: answer.code:44:12: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 44 | signed main() | ^~ answer.code:44:12: note: remove parentheses to default-initialize a variable 44 | signed main() | ^~ | -- answer.code:44:12: note: or replace parentheses with braces to value-initialize a variable answer.code:45:1: error: a function-definition is not allowed here before ‘{’ token 45 | { | ^ answer.code:51:2: error: expected ‘}’ at end of input 51 | } | ^ answer.code:8:1: note: to match this ‘{’ 8 | { | ^