Submission #1109343

# Submission time Handle Problem Language Result Execution time Memory
1109343 2024-11-06T13:24:14 Z Plot_Twist Balloons (CEOI11_bal) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#include<chrono>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

using namespace std;
using namespace chrono;
#define ll long long
#define vl vector<long long>
#define endl '\n'
const int MOD = 1e9 + 7;
void inputv(vl &v) {for(int i = 0; i < (ll)v.size(); i++) cin>>v[i];}
void printv(vl v) {for(auto i : v) cout<<i<<" ";cout<<endl;}

// #define ONLINE_JUDGE

#ifndef ONLINE_JUDGE
#include "template.cpp"
#else
#define debug(...)
#define debugArr(...)
#endif

#define int long long

#define ld long double

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;

int n;
vector<int>arr;
vector<int>maxRad;
vector<ld>ans;

int check(int x1, int x2, ld rad1, ld rad2) {
    ld temp = rad1/rad2;
    int high = 1e16;
    int ans = -1;
    int low = x2+1;
    while(low>=high) {
        int mid = (low+high)/2;
        ld t = (1 + (((ld)x2 - x1)/((ld)mid - x2)));
        t *= t;
        if(t>=temp) {
            ans = mid;
            low = mid+1;
        }
        else high = mid-1;
    }
    return ans;
}

signed main() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        freopen("error.txt","w",stderr);
    #endif
    ios::sync_with_stdio(false); cin.tie(NULL);
    int ts = 1;

    #ifndef ONLINE_JUDGE
    auto start = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
    #endif
    while(ts--) {
        cin>>n;
        arr = maxRad = vector<int>(n);
        for(int i = 0; i < n; i++) cin>>arr[i]>>maxRad[i];
        stack<pair<int,int>>st;
        ans = vector<ld>(n);
        ans[0] = maxRad[0];
        st.push({0,-1});
        for(int i = 1; i < n; i++) {
            while(st.top().second != -1 && st.top().second < arr[i]) st.pop();
            int prev = st.top().first;
            ld rad = min((ld)maxRad[i], ((ld)arr[i]-(ld)arr[prev])*((ld)arr[i]-(ld)arr[prev])/((ld)4.0*ans[prev]));
            ans[i] = rad;
            while(!st.empty() && ans[st.top().first] <= rad) st.pop();
            if(!st.empty()) {
                prev= st.top().first;
                int temp = check(arr[prev], arr[i], ans[prev], ans[i]);
                if(temp!=-1) st.push({i,temp});
            }
            else {
                st.push({i, -1});
            }
        }
        cout<<fixed<<setprecision(3);
        for(int i = 0; i < n; i++) cout<<ans[i]<<endl;

    }
    #ifndef ONLINE_JUDGE
    auto stop = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
    cerr << "Took " << stop - start << "ms" << endl;
    #endif
    
}

Compilation message

bal.cpp:19:10: fatal error: template.cpp: No such file or directory
   19 | #include "template.cpp"
      |          ^~~~~~~~~~~~~~
compilation terminated.