QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#838026 | #9253. Prism Palace | IllusionaryDominance | RE | 0ms | 4244kb | C++20 | 1.2kb | 2024-12-30 18:27:08 | 2024-12-30 18:27:17 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX_N = 200000 + 5;
const double Pi = acos(-1);
int N;
double x[MAX_N], y[MAX_N];
inline ll cross(int x1, int y1, int x2, int y2) {
return 1ll * x1 * y2 - 1ll * y1 * x2;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin >> N;
for (int i = 1; i <= N; i ++) {
cin >> x[i] >> y[i];
}
if (cross(x[2] - x[1], y[2] - y[1], x[3] - x[2], y[3] - y[2]) > 0) {
reverse(x + 1, x + N + 1);
reverse(y + 1, y + N + 1);
}else {
assert(N <= 10);
}
double ans = 0;
for (int i = 1; i <= N; i ++) {
int pre = i > 1 ? i - 1 : N;
int j = i < N ? i + 1 : 1;
int suf = j < N ? j + 1 : 1;
int dxl = x[i] - x[pre], dyl = y[i] - y[pre];
int dxr = x[j] - x[suf], dyr = y[j] - y[suf];
if (cross(dxl, dyl, dxr, dyr) < 0) {
double angl = atan2(dyl, dxl);
double angr = atan2(dyr, dxr);
if (angl < angr) angl += Pi * 2;
ans += (angl - angr) / Pi;
}
}
cout << fixed << setprecision(12) << ans << '\n';
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 4228kb
input:
3 0 0 1 0 0 1
output:
1.000000000000
result:
ok found '1.0000000', expected '1.0000000', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
4 0 0 0 1 1 1 1 0
output:
0.000000000000
result:
ok found '0.0000000', expected '0.0000000', error '-0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 4244kb
input:
4 0 0 0 3 1 2 1 1
output:
0.500000000000
result:
ok found '0.5000000', expected '0.5000000', error '0.0000000'
Test #4:
score: -100
Runtime Error
input:
199996 719157942 80035870 719158808 80033199 719160795 80027070 719162868 80020675 719165635 80012139 719166422 80009711 719166927 80008153 719168388 80003645 719168539 80003179 719168806 80002355 719168864 80002176 719169119 80001389 719171067 79995376 719173806 79986921 719175195 79982633 71917686...