Submission #869187

# Submission time Handle Problem Language Result Execution time Memory
869187 2023-11-03T12:39:30 Z tvladm2009 Balloons (CEOI11_bal) C++17
0 / 100
1 ms 348 KB
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <cassert>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>
#include <numeric>

using namespace std;

typedef long long ll;
typedef long double ld;
const int N = (int)2e5 + 7;
ld x[N], r[N], rad[N];
int n;

struct Circle {
        ld x;
        ld y;
        ld radius;
};

bool check(Circle a, Circle b) {
        ld d = (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
        if (d <= (a.radius + b.radius) * (a.radius + b.radius)) {
                return false;
        }
        return true;
}

int main() {
#ifdef ONLINE_JUDGE
        assert(false);
        ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#else
        FILE* stream;
        freopen("input.txt", "r", stdin);
#endif
        cin >> n;
        for (int i = 1; i <= n; i++) {
                cin >> x[i] >> r[i];
        }
        rad[1] = r[1];
        for (int i = 2; i <= n; i++) {
                ld best = r[i];
                for (int j = 1; j < i; j++) {
                        ld lo = 0.0, hi = r[i], sol = 0.0;
                        for (int step = 1; step <= 100; step++) {
                                ld mi = (lo + hi) / 2;
                                if (check(Circle{rad[j], x[j], rad[j]}, Circle{mi, x[i], mi})) {
                                        lo = mi + 1;
                                        sol = mi;
                                }
                                else {
                                        hi = mi - 1;
                                }
                        }
                        best = min(best, sol);
                }
                rad[i] = best;
        }
        for (int i = 1; i <= n; i++) {
                cout << setprecision(10) << fixed << rad[i] << "\n";
        }
        return 0;
}

Compilation message

bal.cpp: In function 'int main()':
bal.cpp:53:15: warning: unused variable 'stream' [-Wunused-variable]
   53 |         FILE* stream;
      |               ^~~~~~
bal.cpp:54:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |         freopen("input.txt", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Unexpected end of file - double expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Unexpected end of file - double expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Unexpected end of file - double expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Unexpected end of file - double expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Unexpected end of file - double expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Unexpected end of file - double expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Unexpected end of file - double expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Unexpected end of file - double expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Unexpected end of file - double expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Unexpected end of file - double expected
2 Halted 0 ms 0 KB -