QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#626005#9253. Prism Palaceticking_awayWA 74ms12888kbC++202.1kb2024-10-09 22:18:192024-10-09 22:18:20

Judging History

This is the latest submission verdict.

  • [2024-10-09 22:18:20]
  • Judged
  • Verdict: WA
  • Time: 74ms
  • Memory: 12888kb
  • [2024-10-09 22:18:19]
  • Submitted

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 = long 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;
    using pdd = pair<db, db>;
    vector<pdd> 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;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3812kb

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: 3892kb

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: 3832kb

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: 74ms
memory: 12888kb

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'