제출 #1123670

#제출 시각아이디문제언어결과실행 시간메모리
1123670gdragonBalloons (CEOI11_bal)C++20
20 / 100
336 ms6484 KiB
#include <bits/stdc++.h> using namespace std; #define TASK "long" #define fi first #define se second #define ll long long #define pb push_back #define ALL(x) (x).begin(), (x).end() #define GETBIT(mask, i) ((mask) >> (i) & 1) #define MASK(i) ((1LL) << (i)) #define SZ(x) ((int)(x).size()) #define mp make_pair #define CNTBIT(mask) __builtin_popcount(mask) template<class X, class Y> bool maximize(X &x, Y y){ if (x < y) {x = y; return true;} return false;}; template<class X, class Y> bool minimize(X &x, Y y){ if (x > y) {x = y; return true;} return false;}; typedef pair<int, int> ii; const int N = 2e5 + 5; const int inf = 1e9 + 7; const long long INF = (long long)1e18 + 7; const int mod = 1e9 + 7; void add(int &x, int y) {x += y; if (x >= mod) x -= mod;} void sub(int &x, int y) {x -= y; if (x < 0) x += mod;} int mul(int x, int y) {return 1LL * x * y % mod;} // -----------------------------------------// int n; int x[N], radius[N]; long double ans[N]; void read() { cin >> n; for(int i = 1; i <= n; i++) cin >> x[i] >> radius[i]; } void solve() { ans[1] = radius[1]; long double mx = x[1] + radius[1]; int pos = 1; for(int i = 2; i <= n; i++) { long long tmp = radius[i] - ans[pos]; long double dist = (long double) tmp * tmp + (x[i] - x[pos]) * (x[i] - x[pos]); if ((long double)sqrt(dist) > (long double)(ans[pos] + radius[i])) ans[i] = radius[i]; else { long long delta = x[i] - x[pos]; ans[i] = (long double)delta * delta / (long double)(4.0 * ans[pos]); } // cout << pos << endl; if (maximize(mx, (long double)x[i] + ans[i])) pos = i; } cout << fixed << setprecision(3); for(int i = 1; i <= n; i++) cout << ans[i] << endl; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen(TASK".inp", "r")) { freopen(TASK".inp", "r", stdin); freopen(TASK".out", "w", stdout); } int test = 1; // cin >> test; while(test--) { read(); solve(); } return 0; }

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

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