QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#551925#9253. Prism Palaceucup-team4435#AC ✓61ms12624kbC++206.7kb2024-09-07 19:07:412024-09-07 19:07:41

Judging History

你现在查看的是最新测评结果

  • [2024-09-07 19:07:41]
  • 评测
  • 测评结果:AC
  • 用时:61ms
  • 内存:12624kb
  • [2024-09-07 19:07:41]
  • 提交

answer

#include "bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
#define rep1n(i, n) for (int i = 1; i <= (n); ++i)
#define repr(i, n) for (int i = (n) - 1; i >= 0; --i)
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define each(x, a) for (auto &x : a)
#define ar array
#define vec vector
#define range(i, n) rep(i, n)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using str = string;
using pi = pair<int, int>;
using pl = pair<ll, ll>;

using vi = vector<int>;
using vl = vector<ll>;
using vpi = vector<pair<int, int>>;
using vvi = vector<vi>;

int Bit(int mask, int b) { return (mask >> b) & 1; }

template<class T>
bool ckmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool ckmax(T &a, const T &b) {
    if (b > a) {
        a = b;
        return true;
    }
    return false;
}

// [l, r)
template<typename T, typename F>
T FindFirstTrue(T l, T r, const F &predicat) {
    --l;
    while (r - l > 1) {
        T mid = l + (r - l) / 2;
        if (predicat(mid)) {
            r = mid;
        } else {
            l = mid;
        }
    }
    return r;
}


template<typename T, typename F>
T FindLastFalse(T l, T r, const F &predicat) {
    return FindFirstTrue(l, r, predicat) - 1;
}

const ll INF = 2e18;
const int INFi = 1e9;
const int LG = 49;
const int N = 1e4 + 4;

template<typename T>
int normalize(T value, int mod) {
    if (value < -mod || value >= 2 * mod) value %= mod;
    if (value < 0) value += mod;
    if (value >= mod) value -= mod;
    return value;
}

template<int mod>
struct static_modular_int {
    using mint = static_modular_int<mod>;

    int value;

    static_modular_int() : value(0) {}

    static_modular_int(const mint &x) : value(x.value) {}

    template<typename T, typename U = std::enable_if_t<std::is_integral<T>::value>>
    static_modular_int(T value) : value(normalize(value, mod)) {}

    template<typename T>
    mint power(T degree) const {
        degree = normalize(degree, mod - 1);
        mint prod = 1, a = *this;
        for (; degree > 0; degree >>= 1, a *= a)
            if (degree & 1)
                prod *= a;

        return prod;
    }

    mint inv() const {
        return power(-1);
    }

    mint &operator=(const mint &x) {
        value = x.value;
        return *this;
    }

    mint &operator+=(const mint &x) {
        value += x.value;
        if (value >= mod) value -= mod;
        return *this;
    }

    mint &operator-=(const mint &x) {
        value -= x.value;
        if (value < 0) value += mod;
        return *this;
    }

    mint &operator*=(const mint &x) {
        value = int64_t(value) * x.value % mod;
        return *this;
    }

    mint &operator/=(const mint &x) {
        return *this *= x.inv();
    }

    friend mint operator+(const mint &x, const mint &y) {
        return mint(x) += y;
    }

    friend mint operator-(const mint &x, const mint &y) {
        return mint(x) -= y;
    }

    friend mint operator*(const mint &x, const mint &y) {
        return mint(x) *= y;
    }

    friend mint operator/(const mint &x, const mint &y) {
        return mint(x) /= y;
    }

    mint &operator++() {
        ++value;
        if (value == mod) value = 0;
        return *this;
    }

    mint &operator--() {
        --value;
        if (value == -1) value = mod - 1;
        return *this;
    }

    mint operator++(int) {
        mint prev = *this;
        value++;
        if (value == mod) value = 0;
        return prev;
    }

    mint operator--(int) {
        mint prev = *this;
        value--;
        if (value == -1) value = mod - 1;
        return prev;
    }

    mint operator-() const {
        return mint(0) - *this;
    }

    bool operator==(const mint &x) const {
        return value == x.value;
    }

    bool operator!=(const mint &x) const {
        return value != x.value;
    }

    bool operator<(const mint &x) const {
        return value < x.value;
    }

    template<typename T>
    explicit operator T() {
        return value;
    }

    friend std::istream &operator>>(std::istream &in, mint &x) {
        std::string s;
        in >> s;
        x = 0;
        for (const auto c: s)
            x = x * 10 + (c - '0');

        return in;
    }

    friend std::ostream &operator<<(std::ostream &out, const mint &x) {
        return out << x.value;
    }

    static int primitive_root() {
        if constexpr (mod == 1'000'000'007) return 5;
        if constexpr (mod == 998'244'353) return 3;
        if constexpr (mod == 786433) return 10;

        static int root = -1;
        if (root != -1)
            return root;

        std::vector<int> primes;
        int value = mod - 1;
        for (int i = 2; i * i <= value; i++)
            if (value % i == 0) {
                primes.push_back(i);
                while (value % i == 0)
                    value /= i;
            }

        if (value != 1) primes.push_back(value);
        for (int r = 2;; r++) {
            bool ok = true;
            for (auto p: primes) {
                if ((mint(r).power((mod - 1) / p)).value == 1) {
                    ok = false;
                    break;
                }
            }
            if (ok) return root = r;
        }
    }
};

constexpr int MOD = 1'000'000'007;
// constexpr int MOD = 998'244'353;
using mint = static_modular_int<MOD>;

const ld PI = atan2(0, -1);

ld normalize(ld ang) {
    while (ang < 0) ang += 2 * PI;
    while (ang >= 2 * PI) ang -= 2 * PI;
    return ang;
}

void solve() {
    int n; cin >> n;
    vector<pair<ll, ll>> a(n);
    rep(i, n) cin >> a[i].first >> a[i].second;
    vector<pair<ll, ll>> pts(n);
    vector<ld> ang(n);
    rep(i, n) {
        pts[i] = {a[(i + 1) % n].first - a[i].first, a[(i + 1) % n].second - a[i].second};
        ang[i] = atan2(pts[i].second, pts[i].first);
    }
    sort(all(ang));
    ld ans = 0;
    rep(i, n) {
        ld R = normalize(ang[(i + 1) % n] - ang[i]);
        ld L = normalize(ang[i] - ang[(i + n - 1) % n]);
        R -= PI / 2;
        R = min(R, PI / 2);
        L -= PI / 2;
        L = min(L, PI / 2);
        if (-L <= R) {
            ans += (R + L);
        }
    }
    cout << ans / PI << '\n';
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(12) << fixed;
    int t = 1;
//    cin >> t;
    rep(i, t) {
        solve();
    }
    return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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

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: 0
Accepted
time: 58ms
memory: 12624kb

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.000077716803

result:

ok found '0.0000777', expected '0.0000777', error '0.0000000'

Test #5:

score: 0
Accepted
time: 56ms
memory: 12384kb

input:

199999
521578765 315995242
521578784 315995230
521585008 315991299
521590377 315987908
521597318 315983524
521606119 315977965
521610976 315974897
521614329 315972779
521622922 315967351
521631939 315961655
521636172 315958981
521638241 315957674
521643115 315954595
521650976 315949629
521656567 315...

output:

0.000096532179

result:

ok found '0.0000965', expected '0.0000965', error '0.0000000'

Test #6:

score: 0
Accepted
time: 53ms
memory: 12560kb

input:

200000
88808852 208512084
88810113 208513562
88812008 208515783
88812543 208516410
88816806 208521406
88824507 208530431
88825624 208531740
88831723 208538887
88834262 208541862
88838287 208546578
88845440 208554959
88848801 208558897
88855564 208566821
88856869 208568350
88862876 208575388
88868324...

output:

0.000074373701

result:

ok found '0.0000744', expected '0.0000744', error '0.0000000'

Test #7:

score: 0
Accepted
time: 61ms
memory: 12528kb

input:

199998
2857588 37580055
2857908 37582176
2857951 37582461
2858026 37582958
2859295 37591366
2859678 37593903
2860879 37601857
2862301 37611272
2862330 37611464
2863054 37616255
2864429 37625353
2865434 37632002
2865585 37633001
2867092 37642971
2867321 37644486
2867870 37648118
2868343 37651247
2868...

output:

0.000067539683

result:

ok found '0.0000675', expected '0.0000675', error '0.0000000'

Test #8:

score: 0
Accepted
time: 56ms
memory: 12564kb

input:

199999
487716180 333296644
487720319 333294576
487721706 333293883
487731571 333288954
487734599 333287441
487742738 333283374
487744419 333282534
487746174 333281657
487748301 333280594
487750462 333279514
487754846 333277323
487759670 333274912
487762097 333273699
487764676 333272410
487772963 333...

output:

0.000070696702

result:

ok found '0.0000707', expected '0.0000707', error '0.0000000'

Extra Test:

score: 0
Extra Test Passed