제출 #485098

#제출 시각아이디문제언어결과실행 시간메모리
485098XBoRickieBalloons (CEOI11_bal)C++11
100 / 100
448 ms6596 KiB
#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); cin.exceptions(cin.failbit); srand(time(NULL)); }

const int MOD = 1e9 + 7, MOD2 = 1e9 + 9;
// ======================================================================

const int N = 2e5 + 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



int main(int argc, char* argv[]) { FastIO();
    cin >> n;
    FORW(i, 1, n, 1) cin >> x[i] >> r[i];
    FORW(i, 1, n, 1) {
        R[i] = r[i]; int j = i;

        while (sz(ss)) {
            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);
    }

    FORW(i, 1, n, 1) cout << fixed << setprecision(3) << R[i] << endl;

    return 0; }

컴파일 시 표준 에러 (stderr) 메시지

bal.cpp: In function 'int main(int, char**)':
bal.cpp:54:26: warning: unused variable 'j' [-Wunused-variable]
   54 |         R[i] = r[i]; int j = i;
      |                          ^
#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...