#include <bits/stdc++.h>
using namespace std;
// Typedef
typedef long double ld;
typedef long long int int64;
typedef unsigned long long int uint64;
typedef std::pair<int, int> PII;
typedef std::pair<int64, int64> PLL;
typedef std::vector<int> VI;
typedef std::vector<long long> VLL;
// Define For-loop
#define FOR(i, j, k, in) for (int i = (j); i < (k) ; i += (in))
#define FORW(i, j, k, in) for (int i = (j); i <= (k); i += (in))
#define RFOR(i, j, k, in) for (int i = (j); i >= (k); i -= (in))
// Define Data structure func
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define sz(cont) int((cont).size())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
// Define number
#define IINF 0x3f3f3f3f
#define LLINF 1000111000111000111LL
#define PI 3.1415926535897932384626433832795
// Other
#define lend '\n'
#define hardio(name) freopen(name".inp","r",stdin), freopen(name".out","w",stdout);
void FastIO() { std::ios_base::sync_with_stdio(false); std::cin.tie(NULL); srand(time(NULL)); }
const int MOD = 1e9 + 7, MOD2 = 1e9 + 9;
// ======================================================================
const int N = 5e5 + 6;
int n = 0;
double x[N], r[N];
double R[N] = {};
stack<int> ss;
// Gia su hai bong bong bom day ke nhau vi tri i va j
// Khi bong bong' duoc bom day thi tam cua no se la O(x[i], r[i])
// dist(i, j) = (x[i] - x[j])^2 + (r[i] - r[j])^2 = (r[i] + r[j])^2
// (x[i] - x[j])^2 + r[i]^2 - 2r[i]r[j] + r[j]^2 = r[i]^2 + 2r[i]r[j] + r[j]^2
// (x[i] - x[j])^2 = 4r[i][j]
// r[i] = (x[i] - x[j])^2/(4 * r[j]) voi moi j < i
namespace io { const int SIZE = (1 << 20) + 1;
char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
inline void flush() { fwrite (obuf, 1, oS - obuf, stdout); oS = obuf; } // print the remaining part
inline void putc(char x) { *oS++ = x; if (oS == oT) flush (); } // putchar
template<typename A> inline bool read (A &x) {
for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1; else if (c == EOF) return 0;
for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;
return 1; }
inline bool read(char &x) { while((x = gc()) == ' ' || x == '\n' || x == '\r'); return x != EOF; }
inline bool read(string& x) {
while ((c = gc()) == '\n' || c == ' '|| c == '\r'); if (c == EOF) return 0; x.clear();
while (!(c == '\n' || c == ' ' || c == '\r' || c == EOF)) x.push_back(c), c = gc(); return 1;
}
template<typename A,typename ...B>
inline int read(A &x, B &...y) { return read(x) + read(y...); }
template<typename A> inline bool write(A x) {
if (!x) putc('0'); if (x < 0) putc ('-'), x = -x;
while (x) qu[++qr] = x % 10 + '0', x /= 10;
while (qr) putc(qu[qr--]);
return 0; }
inline bool write(char x) { putc(x); return 0; }
inline bool write(const char *x){ while (*x){ putc(*x); ++x; } return 0; }
inline bool write(char *x){ while (*x){ putc(*x); ++x; } return 0; }
template<typename A,typename ...B>
inline bool write(A x,B ...y){ return write(x) || write(y...); }
//no need to call flush at the end manually!
struct Flusher_ {~Flusher_(){ flush(); }} io_flusher_;
} using io::read; using io::putc; using io::write;
int main(int argc, char* argv[]) { FastIO();
cin >> n;
FORW(i, 1, n, 1) {
read(x[i], r[i]);
while (!ss.empty()) {
double rr = (x[i] - x[ss.top()]) * (x[i] - x[ss.top()]) / (4.0 * R[ss.top()]);
R[i] = min(R[i], rr);
if (R[i] < R[ss.top()]) break;
else ss.pop();
}
ss.push(i);
cout << fixed << setprecision(3) << R[i] << '\n';
}
return 0; }
Compilation message
bal.cpp: In function 'bool io::read(A&)':
bal.cpp:55:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
55 | for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;
| ^~~
bal.cpp:55:76: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
55 | for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;
| ^
bal.cpp: In function 'bool io::read(std::string&)':
bal.cpp:59:9: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
59 | while ((c = gc()) == '\n' || c == ' '|| c == '\r'); if (c == EOF) return 0; x.clear();
| ^~~~~
bal.cpp:59:61: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
59 | while ((c = gc()) == '\n' || c == ' '|| c == '\r'); if (c == EOF) return 0; x.clear();
| ^~
bal.cpp:60:9: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
60 | while (!(c == '\n' || c == ' ' || c == '\r' || c == EOF)) x.push_back(c), c = gc(); return 1;
| ^~~~~
bal.cpp:60:93: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
60 | while (!(c == '\n' || c == ' ' || c == '\r' || c == EOF)) x.push_back(c), c = gc(); return 1;
| ^~~~~~
bal.cpp: In function 'bool io::write(A)':
bal.cpp:65:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
65 | if (!x) putc('0'); if (x < 0) putc ('-'), x = -x;
| ^~
bal.cpp:65:28: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
65 | if (!x) putc('0'); if (x < 0) putc ('-'), x = -x;
| ^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
1st numbers differ - expected: '24.0000000000', found: '0.0000000000', error = '24.0000000000' |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
332 KB |
1st numbers differ - expected: '247294217.0000000000', found: '0.0000000000', error = '247294217.0000000000' |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
1st numbers differ - expected: '213.0000000000', found: '0.0000000000', error = '213.0000000000' |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
332 KB |
1st numbers differ - expected: '123.0000000000', found: '0.0000000000', error = '123.0000000000' |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
10 ms |
992 KB |
1st numbers differ - expected: '213.0000000000', found: '0.0000000000', error = '213.0000000000' |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
25 ms |
2024 KB |
1st numbers differ - expected: '15399.0000000000', found: '0.0000000000', error = '15399.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
43 ms |
3432 KB |
1st numbers differ - expected: '7938.0000000000', found: '0.0000000000', error = '7938.0000000000' |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
50 ms |
3828 KB |
1st numbers differ - expected: '5060.0000000000', found: '0.0000000000', error = '5060.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
63 ms |
4660 KB |
1st numbers differ - expected: '1874.0000000000', found: '0.0000000000', error = '1874.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
110 ms |
5584 KB |
1st numbers differ - expected: '2962.0000000000', found: '0.0000000000', error = '2962.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |