QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#625998 | #9253. Prism Palace | ticking_away | WA | 29ms | 6176kb | C++20 | 2.1kb | 2024-10-09 22:16:51 | 2024-10-09 22:16:53 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ui = unsigned int;
using ull = unsigned long long;
using ll = long long;
#define endl '\n'
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int maxn = 2e5 + 10;
const int mod = 1000000007;
#define inl inline
#define fr(i, a, b) for (int i = a; i <= b; i++)
#define ford(i, a, b) for (int i = a; i >= b; i--)
#define forall(i, a) for (auto &i : a)
/**
____ ___ _____
/ ___| _ _ / _ \___ /
\___ \| | | | | | ||_ \
___) | |_| | |_| |__) |
|____/ \__, |\___/____/
|___/
*/
istream &operator>>(istream &in, vector<int> &v)
{
for (auto &i : v)
in >> i;
return in;
}
ostream &operator<<(ostream &out, vector<int> &v)
{
for (auto &i : v)
out << i << " ";
return out;
}
bool _output = 0;
using db = double;
db make(pii a, pii b)
{
db len_a = sqrt(a.first * a.first + a.second * a.second);
db len_b = sqrt(b.first * b.first + b.second * b.second);
db dot = a.first * b.first + a.second * b.second;
db cos = dot / (len_a * len_b);
// cout << cos << endl;
return acos(cos);
}
pii get(pii a, pii b)
{
return {a.first - b.first, a.second - b.second};
}
void solve()
{
int n;
cin >> n;
vector<pii> a(n);
for (auto &i : a)
cin >> i.first >> i.second;
db ans = 0;
vector<db> b(n);
for (int i = 0; i < n; i++)
{
auto p1 = a[i];
auto p2 = a[(i + 1) % n];
auto p3 = a[(i + 2) % n];
auto t1 = get(p1, p2);
auto t2 = get(p3, p2);
b[i] = make(t1, t2);
}
const db PI = acos(-1);
for (int i = 0; i < n; i++)
{
db p1 = b[i], p2 = b[(i + 1) % n];
if (p1 + p2 < PI)
{
ans += PI - p1 - p2;
}
}
ans /= PI;
cout << fixed << setprecision(10) << ans << endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int _ = 1;
if (_output)
cin >> _;
while (_--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 4208kb
input:
3 0 0 1 0 0 1
output:
1.0000000000
result:
ok found '1.0000000', expected '1.0000000', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 4012kb
input:
4 0 0 0 1 1 1 1 0
output:
0.0000000000
result:
ok found '0.0000000', expected '0.0000000', error '-0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 4208kb
input:
4 0 0 0 3 1 2 1 1
output:
0.5000000000
result:
ok found '0.5000000', expected '0.5000000', error '0.0000000'
Test #4:
score: -100
Wrong Answer
time: 29ms
memory: 6176kb
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.0000000000
result:
wrong answer 1st numbers differ - expected: '0.0000777', found: '0.0000000', error = '0.0000777'