Submission #917148

#TimeUsernameProblemLanguageResultExecution timeMemory
917148FucKanhBalloons (CEOI11_bal)C++14
20 / 100
150 ms9788 KiB
#include<bits/stdc++.h> using namespace std; void IOfile(string name) { freopen((name + ".inp").c_str(), "r", stdin); freopen((name + ".out").c_str(), "w", stdout); } pair<int,double> a[200005]; stack<int> st; bool collide2(int x, int y) { double r1 = a[x].second; double r2 = a[y].second; double x1 = a[x].first; double x2 = a[y].first; return ( (r1 + r2) * (r1 + r2) > (x2 - x1) * (x2 - x1) + (r1 - r2) * (r1 - r2) ); } bool collide(double x1, double r1, double x2, double r2) { return ( (r1 + r2) * (r1 + r2) > (x2 - x1) * (x2 - x1) + (r1 - r2) * (r1 - r2) ); } double findr(pair<int, double> a, int bx) { return (a.first - bx) * (a.first - bx) / (4 * a.second); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); // IOfile("TEST"); int n; cin >> n; for (int i =0 ; i <n;i++) { int x,r; cin >> x >> r; a[i] = {x,r}; } st.push(0); for (int i = 1; i < n; i++) { while (st.size()) { a[i].second=min(a[i].second, findr(a[st.top()], a[i].first)); if (a[st.top()].second <= a[i].second) { st.pop(); } else break; } st.push(i); } for (int i = 0; i < n; i++) cout << fixed << setprecision(3) << a[i].second << "\n"; return 0; }

Compilation message (stderr)

bal.cpp: In function 'void IOfile(std::string)':
bal.cpp:5:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 |     freopen((name + ".inp").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bal.cpp:6:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |     freopen((name + ".out").c_str(), "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...