QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#838024 | #9253. Prism Palace | IllusionaryDominance | RE | 0ms | 4168kb | C++20 | 1.2kb | 2024-12-30 18:26:07 | 2024-12-30 18:26:08 |
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(false);
}
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: 4168kb
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: -100
Runtime Error
input:
4 0 0 0 1 1 1 1 0