제출 #1183151

#제출 시각아이디문제언어결과실행 시간메모리
1183151kayumov_muhammadMatching (CEOI11_mat)C++20
0 / 100
553 ms11704 KiB
#include <bits/stdc++.h>

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target(."avx2,bmi,bmi2,lzcnt,popcnt")
#pragma GCC optimize("Ofast")

#ifdef LOCAL
#include "debug/debug.hpp"
#else
#define print(...)
#endif

using ll = int;
using ld = double;
using ull = unsigned long long;
#define str string

#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define ent cout << "\n";
#define sz(v) ll(v.size())

using namespace std;

const long long MOD = 1e9 + 7, inf = 1e18;
ld esp = 1e-7;

ld get_pos(ld x1, ld y1, ld x2, ld y2) {
    // print()
    ld s = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
    return s;
}

void solve() {
    ll n;
    cin >> n;

    ld x[n + 17], r[n + 17];
    ld ans[n + 17];

    vector<pair<ld, ld>> pos;
    cout << fixed << setprecision(7);

    for (ll i = 1; i <= n; i++) {
        cin >> x[i] >> r[i];

        if (sz(pos) == 0) {
            cout << r[i] << '\n';
            pos.push_back({x[i], r[i]});
            ans[i] = r[i];
        } else {
            ld lf = 0, rg = r[i] + esp;
            // print(pos);
            // print(get_pos(0, 9, 8, 0.5));
            // print(get_pos(0, 9, 13, 3.5), 3.5 + 9);
            while (rg - lf > esp) {
                ld mid = (lf + rg) / 2.0;
                // print(mid);

                // print(lf + esp, rg);
                // cout << (rg - lf) << ' ' << esp << '\n';

                ll ok = 1;

                pos.push_back({x[i - 1], ans[i - 1]});

                for (auto c : pos) {
                    if (get_pos(c.fi, c.se, x[i], mid) - (mid + c.se) < esp) {
                        ok = 0;
                    }
                }
                pos.pop_back();

                // print(mid, ok);

                if (ok) {
                    lf = mid;
                } else {
                    rg = mid;
                }
            }

            cout << lf << '\n';

            if (pos[0].fi + pos[0].se - x[i] + lf < esp) {
                pos.pop_back();
                pos.push_back({x[i], lf});
            }

            ans[i] = lf;
        }
    }
}

int32_t main() {
#ifdef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    ll ttest = 1;
    // cin >> ttest;

    for (ll test_number = 1; test_number <= ttest; test_number++) {
        solve();
    }

    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

mat.cpp:4:20: warning: '#pragma GCC option' is not a string [-Wpragmas]
    4 | #pragma GCC target(."avx2,bmi,bmi2,lzcnt,popcnt")
      |                    ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...