QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#554112 | #9253. Prism Palace | acceon128# | WA | 113ms | 17844kb | C++17 | 1.3kb | 2024-09-09 06:11:42 | 2024-09-09 06:11:42 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
ld cross(const pair<int, int>& p1, const pair<int, int>& p2) {
return p1.first * p2.second - p1.second * p2.first;
}
ld dot(const pair<int, int>& p1, const pair<int, int>& p2) {
return 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;
}
if (cross(sub(pi[1], pi[0]), sub(pi[2], pi[0])) < 0) {
reverse(pi.begin(), pi.end());
}
pi.insert(pi.end(), pi.begin(), pi.end());
vector<ld> poly;
for (int i = 1; i <= n; ++i) {
auto x = sub(pi[i + 1], pi[i]);
auto y = sub(pi[i - 1], pi[i]);
poly.push_back(acos(dot(x, y) / sqrt(dot(x, x) * dot(y, y))));
}
poly.insert(poly.end(), poly.begin(), poly.end());
ld ans = 0.0;
for (int i = 0; i < n; ++i) {
ans += max(ld(0.0), ld(M_PI) - ld(poly[i] + poly[i + 1])) * ld(2);
}
cout << fixed << setprecision(12) << ans / ld(M_PI) / ld(2.0) << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3872kb
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: 3768kb
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: 3744kb
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
Wrong Answer
time: 113ms
memory: 17844kb
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.000000000000
result:
wrong answer 1st numbers differ - expected: '0.0000777', found: '0.0000000', error = '0.0000777'