Submission #1286795

#TimeUsernameProblemLanguageResultExecution timeMemory
1286795shidou26Balloons (CEOI11_bal)C++20
40 / 100
234 ms6632 KiB
#include <bits/stdc++.h> using namespace std; #ifdef KURUMI #include "algo/debug.h" #endif #define endl '\n' #define fi first #define se second #define sz(v) (int)v.size() #define all(v) v.begin(), v.end() #define filter(v) v.resize(unique(all(v)) - v.begin()) #define dbg(x) "[" #x << " = " << x << "]" mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); template<typename T1, typename T2> T2 rand(T1 l, T2 r) { return uniform_int_distribution<T2>(l, r)(rng); } template<typename T1, typename T2> T2 wrand(T1 l, T2 r, int seed) { if(seed == 0) return rand(l, r); else return (seed > 0 ? max(rand(l, r), wrand(l, r, seed - 1)) : min(rand(l, r), wrand(l, r, seed + 1))); } template<typename T> bool maximize(T &a, T b) { if(a < b) { a = b; return true; }else return false; } template<typename T> bool minimize(T &a, T b) { if(a > b) { a = b; return true; }else return false; } typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, int> pli; typedef pair<ll, ll> pll; typedef tuple<int, int, int> tp3; const int N = 2e5 + 3; int n; ld x[N], limr[N]; void input() { cin >> n; for(int i = 1; i <= n; i++) { cin >> x[i] >> limr[i]; } } ld distance(ld x, ld y, ld a, ld b) { return sqrt((x - a) * (x - a) + (y - b) * (y - b)); } namespace subtask_1 { bool approve() { return n <= 2000; } ld rad[N]; void execute() { for(int i = 1; i <= n; i++) { if(i == 1) rad[i] = limr[i]; else { ld l = 0, r = limr[i]; for(int rep = 1; rep <= 50; rep++) { ld mid = (l + r) / 2.0; bool passed = true; for(int j = 1; j < i; j++) { if(distance(x[i], mid, x[j], rad[j]) < rad[j] + mid) { passed = false; break; } } if(passed) rad[i] = mid, l = mid; else r = mid; } } } for(int i = 1; i <= n; i++) cout << fixed << setprecision(3) << rad[i] << endl; } } void process() { if(subtask_1::approve()) return subtask_1::execute(); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); #define task "Deeto" if(fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } int testcase = 1; // cin >> testcase; for(int i = 1; i <= testcase; i++) { input(); process(); } cerr << "Saa, watashtachi no deeto hajimemashou" << endl; cerr << "Atarashii kiseki wo koko kara hajimeru shining place nee mou ichido kimi to..." << endl; return 0; }

Compilation message (stderr)

bal.cpp: In function 'int main()':
bal.cpp:106:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  106 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bal.cpp:107:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  107 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#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...