QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#826755 | #9869. Horizon Scanning | Traveler | WA | 210ms | 3896kb | C++20 | 2.3kb | 2024-12-22 15:54:19 | 2024-12-22 15:54:20 |
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;
}
void g(ld &a) {
a = max(a, ld(-0.999999999999999));
a = min(a, ld(0.999999999999999));
}
const ld PI = 3.1415926536;
ld get(Point a, Point b) {
int dt = dot(a, b);
int cro = cross(a, b);
ld le = len(a) * len(b);
ld ddt = 1.0 * dt / le;
ld dcro = 1.0 * cro / le;
g(ddt);
g(dcro);
if(cro > 0) {
return acos(ddt);
} else if(cro < 0) {
return 2.0 * PI - acos(ddt);
} else {
if(dt > 0) return 0;
return PI;
}
return 0;
}
Point O = {0, 0};
bool cmp1(Point a, Point b)
{
return get(O, a) < get(O, b);
}
void solve() {
int n, k;
cin >> n >> k;
vector<Point> a(n);
for(int i = 0; i < n; i++) {
cin >> a[i].x >> a[i].y;
int G = gcd(a[i].x, a[i].y);
a[i].x /= G;
a[i].y /= G;
}
set<pair<int, int>> st;
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] == b[j]) {
if(j % n <= i % n) ans = fmax(ans, 2 * 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: 100
Accepted
time: 1ms
memory: 3804kb
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.1415926983 3.1415926536
result:
ok 5 numbers
Test #2:
score: -100
Wrong Answer
time: 210ms
memory: 3896kb
input:
10000 16 1 -10 -6 -5 -6 -4 9 -2 5 -2 10 1 -7 1 -5 1 6 3 1 4 -9 6 -10 6 -3 6 1 8 -5 8 -4 9 -4 17 4 -9 2 -8 -4 -8 -3 -8 -1 -6 -2 -6 -1 -6 8 -5 -8 -5 10 -4 8 -2 -8 4 -9 4 0 5 -3 8 -5 9 -2 10 10 10 6 -7 2 -4 6 -2 -7 -2 -1 -1 7 1 -9 1 8 3 -4 7 -4 9 -2 14 3 -9 10 -8 -10 -8 -8 -6 -7 -6 -5 -1 -7 -1 -2 0 -1 ...
output:
6.2454673547 5.4977871438 5.0417151475 6.0818681988 5.8782935209 6.1099396407 5.5348072597 5.2416357612 6.2831853072 6.2831853072 5.6084443650 5.8000596424 5.8280844986 5.9179838574 6.0857897474 6.2831853072 6.1964469685 5.6659939157 6.1588303127 6.0529657199 6.0445759847 5.8195376982 5.4977871438 6...
result:
wrong answer 1st numbers differ - expected: '1.6929915', found: '6.2454674', error = '2.6890128'