QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#826698 | #9869. Horizon Scanning | Traveler | WA | 1ms | 4192kb | C++17 | 2.2kb | 2024-12-22 15:28:59 | 2024-12-22 15:28:59 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define int long long
using i64 = long long;
struct Point {
i64 x;
i64 y;
Point(i64 x = 0, i64 y = 0) : x(x), y(y) {}
};
bool operator==(const Point &a, const Point &b) {
return a.x == b.x && a.y == b.y;
}
Point operator+(const Point &a, const Point &b) {
return Point(a.x + b.x, a.y + b.y);
}
Point operator-(const Point &a, const Point &b) {
return Point(a.x - b.x, a.y - b.y);
}
ld len(const Point &a) {
return sqrtl(a.x * a.x + a.y * a.y);
}
//cos
i64 dot(const Point &a, const Point &b) {
return a.x * b.x + a.y * b.y;
}
//sin
i64 cross(const Point &a, const Point &b) {
return a.x * b.y - a.y * b.x;
}
inline bool cmp(Point A, Point B) { return (A.x == B.x) ? (A.y < B.y) : (A.x < B.x); }
bool cmp1(Point a,Point b)
{
if(atan2(a.y,a.x)!=atan2(b.y,b.x))
return atan2(a.y,a.x)<atan2(b.y,b.x);
else return a.x<b.x;
}
// void g(ld &a) {
// a = max(a, ld(-0.999999999999999));
// a = min(a, ld(0.999999999999999));
// }
Point O = {1, 0}, P = {-1, 0};
ld PI = fabs(atan2(abs(cross(O, P)), dot(O, P)));
ld get(Point a, Point b) {
ld ans = fabs(atan2(abs(cross(a, b)), dot(a, b)));
if(cross(a, b) >= 0) {
return ans;
} else {
return 2.0 * PI - ans;
}
}
int tot = 0;
void solve() {
tot++;
int n, k;
cin >> n >> k;
vector<Point> a(n);
for(int i = 0; i < n; i++) {
cin >> a[i].x >> a[i].y;
}
sort(a.begin(), a.end(), cmp1);
vector<Point> b(2 * n);
for(int i = 0; i < n; i++) {
b[i] = b[i + n] = a[i];
}
ld ans = 0;
for(int i = 0; i < n; i++) {
int j = i + k;
if(b[i].x * b[j].y == b[j].x * b[i].y) ans = fmax(ans, 2.0 * PI);
ans = fmax(ans, get(b[i], b[j]));
}
cout << ans << "\n";
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cout << fixed << setprecision(10);
int T = 1;
cin >> T;
while(T--) solve();
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 4192kb
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.1415926546 6.2831853072
result:
wrong answer 5th numbers differ - expected: '3.1415927', found: '6.2831853', error = '1.0000000'