제출 #1312390

#제출 시각아이디문제언어결과실행 시간메모리
1312390ericl23302Balloons (CEOI11_bal)C++20
0 / 100
2093 ms4348 KiB
#include <bits/stdc++.h> using namespace std; bool checkIntersect(int x1, double y1, int x2, double y2) { return (sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2)) < (double)(y1 + y2)); }; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<pair<int, int>> balloons(n); for (auto& i : balloons) cin >> i.first >> i.second; vector<double> res(n); stack<pair<int, double>> stk; for (int i = 0; i < n; ++i) { while (stk.size() >= 2) { auto two = stk.top(); stk.pop(); auto one = stk.top(); double l = 0, h = balloons[i].second; while (h - l > 1e-9) { double mid = (l + h) / 2; bool res1 = checkIntersect(one.first, one.second, balloons[i].first, mid), res2 = checkIntersect(two.first, two.second, balloons[i].first, mid); if (res1 && res2) h = mid; else if (!res1 && !res2) l = mid; else break; } bool res1 = checkIntersect(one.first, one.second, balloons[i].first, l), res2 = checkIntersect(two.first, two.second, balloons[i].first, l); if (res2 && !res1) { stk.push(two); break; } } if (stk.empty()) { res[i] = balloons[i].second; stk.push(balloons[i]); continue; } auto cur = stk.top(); double l = 0, h = balloons[i].second; while (h - l > 1e-9) { double mid = (l + h) / 2; if (checkIntersect(cur.first, cur.second, balloons[i].first, mid)) h = mid; else l = mid; } res[i] = l; stk.emplace(balloons[i].first, l); } for (auto& i : res) cout << i << '\n'; return 0; }
#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...