답안 #1101892

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1101892 2024-10-17T07:05:30 Z InvMOD Balloons (CEOI11_bal) C++14
20 / 100
135 ms 11336 KB
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define gcd __gcd
#define vsz(v) (int) v.size()
#define pb push_back
#define pi pair<int,int>
#define all(v) (v).begin(), (v).end()
#define compact(v) (v).erase(unique(all(v)), (v).end())
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
///#define int long long

using ll = long long;
using ld = long double;
using ull = unsigned long long;

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

const int N = 2e5+5;
const ll MOD = 1e9+7;
const ll INF = 1e18;

ll square(int x){
    return (1ll * x * x);
}

int n;
ld x[N], r[N];
ld radius[N];

ld calc_dist(ld x1, ld r1, ld x2, ld mxR2){
    ld r2 = square(x1- x2) / (4 * r1);
    return min(r2, mxR2);
}

void solve()
{
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> x[i] >> r[i];
    }

    stack<int> st;
    for(int i = 1; i <= n; i++){
        if(!st.empty()){
            int cur_top = st.top();
            ld pre_dist = calc_dist(x[st.top()], radius[st.top()], x[i], r[i]);
            st.pop();

            while(!st.empty()){
                if(calc_dist(x[st.top()], radius[st.top()], x[i], r[i]) <= pre_dist){
                    pre_dist = calc_dist(x[st.top()], radius[st.top()], x[i], r[i]);
                    cur_top = st.top();
                    st.pop();
                }
                else break;
            }
            if(pre_dist <= r[i]) st.push(cur_top);
        }
        if(st.empty()){
            radius[i] = r[i];
        }
        else{
            radius[i] = calc_dist(x[st.top()], radius[st.top()], x[i], r[i]);
        }
        st.push(i);
    }

    for(int i = 1; i <= n; i++){
        cout << fixed << setprecision(3) << radius[i] <<"\n";
    }
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    #define name "InvMOD"
    if(fopen(name".INP", "r")){
        freopen(name".INP","r",stdin);
        freopen(name".OUT","w",stdout);
    }

    int t = 1; //cin >> t;
    while(t--) solve();
    return 0;
}

Compilation message

bal.cpp: In function 'int main()':
bal.cpp:85:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   85 |         freopen(name".INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
bal.cpp:86:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   86 |         freopen(name".OUT","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4432 KB 10 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4432 KB 2 numbers
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 4432 KB 17th numbers differ - expected: '213.0000000000', found: '234.0000000000', error = '21.0000000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4432 KB 114th numbers differ - expected: '39.0180000000', found: '56.0000000000', error = '16.9820000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 8784 KB 653rd numbers differ - expected: '96.2810000000', found: '123.0000000000', error = '26.7190000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 43 ms 9032 KB 14174th numbers differ - expected: '0.7720000000', found: '1.3710000000', error = '0.5990000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 96 ms 9476 KB 7466th numbers differ - expected: '2.8320000000', found: '3.7070000000', error = '0.8750000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 81 ms 9692 KB 4793rd numbers differ - expected: '0.9540000000', found: '10.6220000000', error = '9.6680000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 107 ms 10316 KB 1785th numbers differ - expected: '2.2550000000', found: '10.0000000000', error = '7.7450000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 135 ms 11336 KB 2723rd numbers differ - expected: '859.0470000000', found: '862.0000000000', error = '2.9530000000'
2 Halted 0 ms 0 KB -