Submission #917148

# Submission time Handle Problem Language Result Execution time Memory
917148 2024-01-27T10:20:32 Z FucKanh Balloons (CEOI11_bal) C++14
20 / 100
150 ms 9788 KB
#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

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 time Memory Grader output
1 Correct 1 ms 344 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB 2nd numbers differ - expected: '252735385.4379999936', found: '0.9330000000', error = '252735384.5049999952'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 344 KB 506th numbers differ - expected: '365.0000000000', found: '-2481854.0649999999', error = '2482219.0649999999'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 3152 KB 655th numbers differ - expected: '591.0000000000', found: '-2402336.3029999998', error = '2402927.3029999998'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 3848 KB 4th numbers differ - expected: '15396.0000000000', found: '-8148.5510000000', error = '23544.5510000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 80 ms 5568 KB 7234th numbers differ - expected: '7160.0000000000', found: '-2398141.9989999998', error = '2405301.9989999998'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 81 ms 5972 KB 4643rd numbers differ - expected: '2427.0000000000', found: '-2355611.7020000000', error = '2358038.7020000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 124 ms 7180 KB 1734th numbers differ - expected: '1856.0220000000', found: '-2324667.3859999999', error = '2326523.4079999998'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 150 ms 9788 KB 2723rd numbers differ - expected: '859.0470000000', found: '-2333711.4849999999', error = '2334570.5319999997'
2 Halted 0 ms 0 KB -