# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
648772 | wyhong3103 | Balloons (CEOI11_bal) | C++14 | 1675 ms | 15288 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define all(x) begin(x),end(x)
#define fir first
#define sec second
#define sz(x) x.size()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<int>;
using pi = pair<int,int>;
using db = double;
using ldb = long double;
using pldb = pair<ldb, ldb>;
using pdb = pair<db,db>;
using pll = pair<ll,ll>;
using vll = vector<ll>;
const double EPS = (1e-6);
void setio(string s){
freopen((s + ".in").c_str(),"r",stdin);
freopen((s + ".out").c_str(),"w",stdout);
}
ldb dist(pldb a, pldb b){
return hypot(abs(a.fir-b.fir), abs(a.sec-b.sec));
}
void solve(){
int n;
cin >> n;
vector<pldb> a(n);
for(auto& i : a) cin >> i.fir >> i.sec;
vector<ldb> res(n);
//{loc, radius}, monotonic radius
stack<pldb> s;
for(int i{}; i < n; i++){
ldb cur_hi = a[i].sec;
while (!s.empty()){
ldb lo = 0, hi = cur_hi;
for(int j{}; j < 50; j++){
ldb mid = lo + (hi-lo)/2;
if (dist(s.top(), {a[i].fir, mid}) > mid+s.top().sec) lo = mid;
else hi = mid;
}
cur_hi = lo;
if (lo > s.top().sec){
s.pop();
}else break;
}
res[i] = cur_hi;
s.push({a[i].fir, cur_hi});
}
cout << setprecision(8) << fixed;
for(auto& i : res) cout << i << '\n';
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
while(t--){
solve();
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |