提出 #72811356


ソースコード 拡げる

// https://atcoder.jp/contests/typical90/tasks/typical90_009
// Wed 28 Jan 2026 09:41:39 PM JST
#include <bits/stdc++.h>
using namespace std;
// #include <atcoder/all>
// using namespace atcoder;
// using mint = modint998244353;
// using mint = modint1000000007;
// using vmint = vector<mint>;
// modint::set_mod(10);
// using mint = modint;
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using int128 = int128_t;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i, n) for (long long int i = 0; i < (n); ++i)
#define rep2(i, k, n) for (long long int i = (k); i < (n); ++i)
using ll = long long;
using vint = vector<int>;
using vll = vector<ll>;
using vvint = vector<vector<int>>;
using vvll = vector<vector<ll>>;

// const ll INF = (ll)2e18+9;
// const int INF = (int)2e9 + 7;

template <typename T>
void chmin(T& a, T b) { a = min(a, b); }
template <typename T>
void chmax(T& a, T b) { a = max(a, b); }

template <typename T>
void print(vector<T> v) {
    int n = v.size();
    rep(i, n) {
        if (i == 0)
            cout << v[i];
        else
            cout << ' ' << v[i];
    }
    cout << endl;
}

void yesno(bool x) { cout << (x ? "Yes" : "No") << '\n'; }

void Yes() { yesno(true); }

void No() { yesno(false); }

// ceil(a/b)
ll ceil(ll a, ll b) { return (a + b - 1) / b; }

// floor(a/b)
ll floor(ll a, ll b) { return a / b; }

struct Point {
    long long x, y;

    // 上半平面判定
    int is_up() const {
        if (y > 0) return 0;
        if (y == 0 && x > 0) return 0;
        return 1;
    }

    // 外積
    long long cross(const Point& other) const {
        return x * other.y - y * other.x;
    }

    // 内積
    long long dot(const Point& other) const {
        return x * other.x + y * other.y;
    }

    // ノルム^2
    long long norm2() const {
        return x * x + y * y;
    }

    // 偏角ソート用 comparator
    bool operator<(const Point& other) const {
        int h1 = is_up();
        int h2 = other.is_up();
        if (h1 != h2) return h1 < h2;
        return cross(other) > 0;
    }

    // ===== 角度計算 =====
    // this と other のなす角(0〜π, ラジアン)
    double angle(const Point& other) const {
        double d = (double)dot(other);
        double n = sqrt((double)norm2() * other.norm2());
        double c = d / n;

        return acos(clamp(c, -1.0, 1.0));
    }

    // 角度(度)
    double angle_deg(const Point& other) const {
        return angle(other) * 180.0 / M_PI;
    }
};

void solve();

int main() {
    solve();
    return 0;
}

void solve() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    ll N;
    cin >> N;
    vll X(N), Y(N);
    rep(i, N) cin >> X[i] >> Y[i];

    double ans = 0.0;
    rep(j, N) {
        vector<Point> pts;
        rep(i, N) {
            if (i == j) continue;
            pts.emplace_back(X[i] - X[j], Y[i] - Y[j]);
        }
        sort(all(pts));

        ll M = N - 1;
        rep(i, M) pts.push_back(pts[i]);

        ll r = 0;
        rep(l, M) {
            if (r < l) r = l;
            while (r + 1 < l + M && pts[l].cross(pts[r + 1]) >= 0) r++;

            chmax(ans, pts[l].angle_deg(pts[r]));
            if (r + 1 < l + M)
                chmax(ans, pts[l].angle_deg(pts[r + 1]));
        }
    }

    printf("%.9lf\n", ans);
}

提出情報

提出日時
問題 009 - Three Point Angle(★6)
ユーザ goropikari
言語 C++23 (GCC 15.2.0)
得点 6
コード長 3525 Byte
結果 AC
実行時間 419 ms
メモリ 4400 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 6 / 6
結果
AC × 4
AC × 29
セット名 テストケース
Sample Sample_1.txt, Sample_2.txt, Sample_3.txt, Sample_4.txt
All Random_1.txt, Random_2.txt, Random_3.txt, Random_4.txt, Random_5.txt, Random_6.txt, Random_7.txt, Random_8.txt, Regular_Polygon_1.txt, Regular_Polygon_2.txt, Regular_Polygon_3.txt, Regular_Polygon_4.txt, Regular_Polygon_5.txt, Regular_Polygon_6.txt, Regular_Polygon_7.txt, Regular_Polygon_8.txt, Sample_1.txt, Sample_2.txt, Sample_3.txt, Sample_4.txt, Small_1.txt, Small_2.txt, Small_3.txt, Small_4.txt, Small_5.txt, Small_6.txt, Small_7.txt, Small_8.txt, Three_Linear_1.txt
ケース名 結果 実行時間 メモリ
Random_1.txt AC 10 ms 4244 KiB
Random_2.txt AC 208 ms 4132 KiB
Random_3.txt AC 32 ms 4204 KiB
Random_4.txt AC 67 ms 4164 KiB
Random_5.txt AC 168 ms 4164 KiB
Random_6.txt AC 37 ms 4272 KiB
Random_7.txt AC 313 ms 4292 KiB
Random_8.txt AC 419 ms 4400 KiB
Regular_Polygon_1.txt AC 1 ms 4064 KiB
Regular_Polygon_2.txt AC 1 ms 3964 KiB
Regular_Polygon_3.txt AC 105 ms 4144 KiB
Regular_Polygon_4.txt AC 118 ms 4272 KiB
Regular_Polygon_5.txt AC 61 ms 4148 KiB
Regular_Polygon_6.txt AC 182 ms 4400 KiB
Regular_Polygon_7.txt AC 92 ms 4148 KiB
Regular_Polygon_8.txt AC 278 ms 4344 KiB
Sample_1.txt AC 1 ms 4076 KiB
Sample_2.txt AC 1 ms 3960 KiB
Sample_3.txt AC 1 ms 4008 KiB
Sample_4.txt AC 1 ms 4016 KiB
Small_1.txt AC 1 ms 4016 KiB
Small_2.txt AC 1 ms 4016 KiB
Small_3.txt AC 1 ms 4016 KiB
Small_4.txt AC 1 ms 4088 KiB
Small_5.txt AC 1 ms 4016 KiB
Small_6.txt AC 1 ms 4016 KiB
Small_7.txt AC 1 ms 4008 KiB
Small_8.txt AC 1 ms 3964 KiB
Three_Linear_1.txt AC 1 ms 3860 KiB