답안 #941480

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
941480 2024-03-09T01:54:55 Z dwuy Balloons (CEOI11_bal) C++14
10 / 100
633 ms 14400 KB
#include <bits/stdc++.h>

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define file(a) freopen(a".inp","r",stdin); freopen(a".out", "w",stdout)
#define fi first
#define se second
#define endl "\n"
#define len(s) int32_t(s.length())
#define MASK(k)(1LL<<(k))
#define TASK "test"
#define int long long
#define double long double

using namespace std;

typedef tuple<int, int, int> tpiii;
typedef pair<double, double> pdd;
typedef pair<int, int> pii;
typedef long long ll;

const long long OO = 1e18;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MX = 200005;

int n;
pdd a[MX];
pdd v[MX];

void nhap(){
    cin >> n;
    for(int i=1; i<=n; i++) cin >> a[i].fi >> a[i].se;
}

double sqr(double x){
    return x*x;
}

double euler(pdd a, pdd b){
    return sqrt(sqr(a.fi - b.fi) + sqr(a.se - b.se));
}

double dis(pdd ball, double p){
    double lo=0, hi=INF;
    for(int t=0; t<45; t++){
        double mid = (lo+hi)/2;
        if(euler(ball, {p, mid}) >= mid + ball.se) lo = mid;
        else hi = mid;
    }
    return (lo + hi)/2;
}

void solve(){   
    int id = 0;
    // for(int i=1; i<=n; i++){ 
    //     for(int j=1; j<i; j++) a[i].se = min(a[i].se, dis(a[j], a[i].fi));
    //     cout << setprecision(3) << fixed << a[i].se << endl;
    // }
    for(int i=1; i<=n; i++){
        while(id>1){
            double dis1 = dis(v[id], a[i].fi);
            if(a[i].se < dis1) break;
            double dis2 = dis(v[id - 1], a[i].fi);
            if(dis1 > dis2) id--;
            else break;
        }
        v[id+1] = {a[i].fi, min(a[i].se, id==0? 1e10 : dis(v[id], a[i].fi))};
        id++;
        cout << fixed << setprecision(3) << v[id].se << '\n';
    }
}

int32_t main(){
    fastIO;
    //file(TASK);

    nhap();
    solve();

    return 0;
}




# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB 5th numbers differ - expected: '17.1630000000', found: '99.0000000000', error = '81.8370000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB 2 numbers
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 2396 KB 3rd numbers differ - expected: '0.0420000000', found: '3.0000000000', error = '2.9580000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 2396 KB 114th numbers differ - expected: '39.0180000000', found: '56.0000000000', error = '16.9820000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 64 ms 6940 KB 196th numbers differ - expected: '100.7250000000', found: '111.0000000000', error = '10.2750000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 173 ms 7116 KB 13945th numbers differ - expected: '0.0140000000', found: '7.0000000000', error = '6.9860000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 321 ms 11524 KB 7236th numbers differ - expected: '0.0070000000', found: '7.0000000000', error = '6.9930000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 383 ms 11864 KB 4645th numbers differ - expected: '0.0260000000', found: '8.0000000000', error = '7.9740000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 494 ms 14304 KB 1734th numbers differ - expected: '1856.0220000000', found: '1865.0000000000', error = '8.9780000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 633 ms 14400 KB 2716th numbers differ - expected: '22.1690000000', found: '43.0000000000', error = '20.8310000000'
2 Halted 0 ms 0 KB -