Submission #445476

# Submission time Handle Problem Language Result Execution time Memory
445476 2021-07-18T08:10:12 Z Nihal_9936 Balloons (CEOI11_bal) C++17
0 / 100
211 ms 6752 KB
#include <bits/stdc++.h>
using namespace std;
 

 
 
template<typename T1, typename T2>istream& operator>>(istream& in, pair<T1, T2>& a) { return in >> a.first >> a.second; }
template<typename T1, typename T2>ostream& operator<<(ostream& out, pair<T1, T2> a) { return out << a.first << " " << a.second;}
template<typename T> void print(T t) { cout << t <<' '; }
template<typename T, typename... Args> void print(T t, Args... args) { print(t);print(args...); }
string operator*=(string& s, int cnt) { string t = s;for (size_t i = 1; i < cnt; i++)s += t;return s; }
string operator*(string s, int cnt) { return s *= cnt; }
 
 
#define int               long long 
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define allr(x)           (x).rbegin(),(x).rend()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define len(x)             (int)((x).size())
#define elif              else if
#define add               insert
#define append            push_back
#define pop               pop_back 
#define str               string
#define in                :
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define vi                vector<int>
#define vii               vector<pii>
#define mi                map<int,int>
#define mii               map<pii,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define rrep(i,a,b)       for(int i=a;i>b;i--)
#define el                 '\n'
#define printl(arg) cout << arg << endl
// #define print(arg) cout << arg
#define inputa(arg) for (auto& e : arg) cin >> e
#define printa(arg) for (auto& e : arg) print(e);
#define printr(arg) { printl(arg);return; }
#define printd(arg) printf("%0.3lf\n", arg)
 
 
const int mod=1e9+7;
// const int INF=1e18;
const int MAX_N=4e5+2;

 
int n,m,k,x,y,z,t,q,counter;
// vector<vector<vector<int>>> dp(101 , vector<vector<int>>(101, vector<int>(101)));
// vector<vector<int>>dp(5001, vi(5001)),ndp(5001,vi(5001));
// vi fac;
// map<int,int> d;



void code(){
            cin>>n;
            double R,x;
            vector<double> ans;
            deque<vector<double>>dq;
            rep(i,0,n){
                cin>>x>>R;
                if(len(dq)==0){
                    dq.append({x,R});
                    ans.append(R);
                }else{
                    double ck_r=1000000000.0000000000;
                    while(len(dq)){
                        double x1=(dq.back())[0],r1=(dq.back())[1];
                        double r2=((x1-x)*(x1-x))/(4*r1);
                        if(ck_r<r2){
                            ans.append(ck_r);
                            dq.append({x,ck_r});
                            break;
                        }
                        ck_r=r2;

                        if(r2>=R){
                            if(R>=r1){
                                dq.pop();
                                continue;
                            }else{
                                ans.append(R);
                                dq.append({x,R});
                                break;
                            }
                        }else{
                            if(r2>=r1){
                                dq.pop();
                            }else{
                                ans.append(r2);
                                dq.append({x,r2});
                                break;
                            }
                        }
                    }
                    if(len(ans)==i){
                        ans.append(R);
                        dq.append({x,R});
                    }
                }
            }
            for(auto& i in ans){
                printd(i);
            }
            
}


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    // freopen("spainting.in", "r", stdin);
    // freopen("spainting.out", "w", stdout);
    int t = 1;
    // cin>>t;
    while(t--) code();
    return 0;
}

Compilation message

bal.cpp: In function 'std::string operator*=(std::string&, int)':
bal.cpp:11:75: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   11 | string operator*=(string& s, int cnt) { string t = s;for (size_t i = 1; i < cnt; i++)s += t;return s; }
      |                                                                         ~~^~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB 6th numbers differ - expected: '21.0000000000', found: '90.9060000000', error = '69.9060000000'
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB 2nd numbers differ - expected: '252735385.4379999936', found: '1000000000.0000000000', error = '747264614.5620000362'
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB 6th numbers differ - expected: '213.0000000000', found: '238.0000000000', error = '25.0000000000'
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 332 KB 5th numbers differ - expected: '117.0000000000', found: '122.0530000000', error = '5.0530000000'
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 1096 KB 10th numbers differ - expected: '202.0000000000', found: '207.0310000000', error = '5.0310000000'
# Verdict Execution time Memory Grader output
1 Incorrect 58 ms 2428 KB 4th numbers differ - expected: '15396.0000000000', found: '15397.0000000000', error = '1.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 117 ms 4352 KB 13th numbers differ - expected: '7920.0000000000', found: '7925.0010000000', error = '5.0010000000'
# Verdict Execution time Memory Grader output
1 Incorrect 134 ms 5160 KB 4th numbers differ - expected: '5055.0000000000', found: '5060.0010000000', error = '5.0010000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 199 ms 6752 KB 14th numbers differ - expected: '1861.0000000000', found: '1862.0000000000', error = '1.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 211 ms 6364 KB 10th numbers differ - expected: '2952.0000000000', found: '2955.0010000000', error = '3.0010000000'
2 Halted 0 ms 0 KB -