QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#554115 | #9253. Prism Palace | acceon128# | WA | 127ms | 4788kb | C++23 | 1.5kb | 2024-09-09 06:24:03 | 2024-09-09 06:24:04 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
const ld PI = acosl(-1);
ld cross(const pair<int, int>& p1, const pair<int, int>& p2) {
return ld(p1.first * p2.second - p1.second * p2.first);
}
ld dot(const pair<int, int>& p1, const pair<int, int>& p2) {
return ld(p1.first * p2.first + p1.second * p2.second);
}
pair<int, int> sub(const pair<int, int>& p1, const pair<int, int>& p2) {
return make_pair(p1.first - p2.first, p1.second - p2.second);
}
int main() {
int n;
cin >> n;
vector<pair<int, int>> pi(n);
for (int i = 0; i < n; ++i) {
cin >> pi[i].first >> pi[i].second;
}
ld ans = 0.0;
const ld PI = acosl(-1.0);
for (int i = 0; i < n; ++i) {
int prev = (i - 1 + n) % n;
int cur = (i + 1) % n;
int nxt = (i + 2) % n;
pair<int, int> vector1 = sub(pi[prev], pi[i]);
pair<int, int> vector2 = sub(pi[cur], pi[i]);
pair<int, int> vector3 = sub(pi[nxt], pi[cur]);
pair<int, int> vector4 = sub(pi[i], pi[cur]);
ld len1 = sqrtl(dot(vector1, vector1));
ld len2 = sqrtl(dot(vector2, vector2));
ld len3 = sqrtl(dot(vector3, vector3));
ld len4 = sqrtl(dot(vector4, vector4));
ld angle1 = acosl(dot(vector1, vector2) / (len1 * len2));
ld angle2 = acosl(dot(vector3, vector4) / (len3 * len4));
ans += max(0.0L, PI - angle1 - angle2);
}
cout << fixed << setprecision(18) << ans / PI << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3888kb
input:
3 0 0 1 0 0 1
output:
1.000000000000000000
result:
ok found '1.0000000', expected '1.0000000', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3768kb
input:
4 0 0 0 1 1 1 1 0
output:
0.000000000000000000
result:
ok found '0.0000000', expected '0.0000000', error '-0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3760kb
input:
4 0 0 0 3 1 2 1 1
output:
0.500000000000000000
result:
ok found '0.5000000', expected '0.5000000', error '0.0000000'
Test #4:
score: -100
Wrong Answer
time: 127ms
memory: 4788kb
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:
0.000000000000000000
result:
wrong answer 1st numbers differ - expected: '0.0000777', found: '0.0000000', error = '0.0000777'