QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#556381 | #9253. Prism Palace | Repeater# | WA | 48ms | 6180kb | C++20 | 1.4kb | 2024-09-10 17:28:13 | 2024-09-10 17:28:13 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using db = double;
const db eps = 1e-9;
int sign(db a){ return a < -eps ? -1 : a > eps; }
int cmp(db a, db b) { return sign(a - b); }
struct P {
db x, y;
P operator+(P p) { return {x + p.x, y + p.y}; }
P operator-(P p) { return {x - p.x, y - p.y}; }
bool operator<(P p) const {
int c = cmp(x, p.x);
if(c) return c == -1;
return cmp(y, p.y) == -1;
}
bool operator==(P p) const {
return cmp(x, p.x) == 0 && cmp(y, p.y) == 0;
}
db dot(P p){ return x * p.x + y * p.y; }
db det(P p){ return x * p.y - y * p.x; }
};
db rad(P p1, P p2){
return atan2(p1.det(p2), p1.dot(p2));
}
#define cross(p1, p2, p3) ((p2.x - p1.x) * (p3.y - p1.y) - (p3.x - p1.x) * (p2.y - p1.y))
#define crossOp(p1, p2, p3) sign(cross(p1, p2, p3))
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<P> p(n);
for(int i = 0; i < n; i++)
cin >> p[i].x >> p[i].y;
db ans = 0;
for(int i = 0; i < n; i++){
P a = p[(i + 1) % n] - p[i];
P b = p[(i + n - 2) % n] - p[(i + n - 1) % n];
// cerr << fixed << setprecision(20) << rad(a, b) << "\n";
// cerr << a.x << " " << a.y << "|" << b.x << " " << b.y << "\n";
ans += max(0.0, -rad(a, b));
}
// for(auto i : h)
// cerr << i.x << " " << i.y << "\n";
ans = ans / acos(-1.0);
cout << fixed << setprecision(20) << ans << "\n";
}
/*
4
0 0
0 3
1 2
1 1
*/
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 4264kb
input:
3 0 0 1 0 0 1
output:
1.00000000000000000000
result:
ok found '1.0000000', expected '1.0000000', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3892kb
input:
4 0 0 0 1 1 1 1 0
output:
0.00000000000000000000
result:
ok found '0.0000000', expected '0.0000000', error '-0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 4024kb
input:
4 0 0 0 3 1 2 1 1
output:
0.50000000000000000000
result:
ok found '0.5000000', expected '0.5000000', error '0.0000000'
Test #4:
score: -100
Wrong Answer
time: 48ms
memory: 6180kb
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...
output:
199992.00007771790842525661
result:
wrong answer 1st numbers differ - expected: '0.0000777', found: '199992.0000777', error = '199992.0000000'