이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define pii pair<ll, ll>
#define st first
#define nd second
#define file "test"
using namespace std;
const long long INF = 1e18;
const long long N = 2e5 + 5;
const long long eps = 1e-6;
stack <int> st;
ll x[N], n;
double r[N];
bool touch(int i, int j) {
double c = r[i] + r[j]; c = c * c;
double a = r[i] - r[j]; a = a * a;
double b = x[j] - x[i]; b = b * b;
return c - a >= b;
}
double cal(int i, int j) {
if (i == 0) return r[j];
double a = r[i], b = x[j] - x[i];
double ans = b * b / ((double)4.0 * a);
return min(ans, r[j]);
}
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
//freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout);
#endif
cin >> n;
st.push(0);
for (int i = 1; i <= n; i ++) {
cin >> x[i] >> r[i];
while (st.size() > 1 && !touch(st.top(), i) && r[i] > r[st.top()]) st.pop();
while (st.size() > 1 && touch(st.top(), i)) {
r[i] = cal(st.top(), i);
if (r[i] < r[st.top()]) break;
st.pop();
while (st.size() > 1 && !touch(st.top(), i) && r[i] > r[st.top()]) st.pop();
}
st.push(i);
cout << setprecision(3) << fixed << r[i] << '\n';
}
return 0;
}
/** /\_/\
* (= ._.)
* / >🍵 \>🍮
**/
컴파일 시 표준 에러 (stderr) 메시지
bal.cpp:56:9: warning: "/*" within comment [-Wcomment]
56 | /** /\_/\
|
# | 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... |