Submission #62936

# Submission time Handle Problem Language Result Execution time Memory
62936 2018-07-31T01:22:23 Z Benq Mobile (BOI12_mobile) C++11
Compilation error
0 ms 0 KB
#include#inclu  <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 1000001;
 
int N,L;
pi v[MX];
ld tmp[MX];
 
ld perp(pd x, pd y) {
    return (y.f*y.f+y.s*y.s-x.f*x.f-x.s*x.s)/(2*y.f-2*x.f);
}
 
ld dist(pd a, pd b) {
    return sqrt(pow(a.f-b.f,2)+pow(a.s-b.s,2));
}
 
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N >> L;
    int nex = 0;
    F0R(i,N) {
        int x,y; cin >> x >> y; y = abs(y);
        if (nex && v[nex-1].f == x) {
            if (y >= v[nex-1].s) continue;
            else nex --;
        }
        while (nex && tmp[nex-1] >= perp(v[nex-1],{x,y})) nex --;
        v[nex] = {x,y};
        if (nex) tmp[nex] = perp(v[nex-1],v[nex]);
        nex ++;
    }
    ld ans = 0;
    F0R(i,nex) {
        ld mn = (i == 0 ? -INF : tmp[i]);
        ld mx = (i == nex-1 ? INF : tmp[i+1]);
        if (mx < 0 || mn > L) continue;
        mn = max(mn,(ld)0), mx = min(mx,(ld)L);
        ans = max(ans,dist(v[i],{mn,0}));
        ans = max(ans,dist(v[i],{mx,0}));
    }
    cout << fixed << setprecision(6) << ans;
}
 
/* Look for:
* the exact constraints (multiple sets are too slow for n=10^6 :( ) 
* special cases (n=1?)
* overflow (ll vs int?)
* array bounds
*/

Compilation message

mobile.cpp:2:9: error: #include expects "FILENAME" or <FILENAME>
 #include#inclu  <bits/stdc++.h>
         ^
mobile.cpp:11:9: error: 'complex' does not name a type
 typedef complex<ld> cd;
         ^~~~~~~
mobile.cpp:22:16: error: 'cd' was not declared in this scope
 typedef vector<cd> vcd;
                ^~
mobile.cpp:22:16: note: suggested alternative: 'vd'
 typedef vector<cd> vcd;
                ^~
                vd
mobile.cpp:22:18: error: template argument 1 is invalid
 typedef vector<cd> vcd;
                  ^
mobile.cpp:22:18: error: template argument 2 is invalid
mobile.cpp: In function 'int main()':
mobile.cpp:57:35: error: 'cin' was not declared in this scope
     ios_base::sync_with_stdio(0); cin.tie(0);
                                   ^~~
mobile.cpp:57:35: note: suggested alternative: 'sin'
     ios_base::sync_with_stdio(0); cin.tie(0);
                                   ^~~
                                   sin
mobile.cpp:80:5: error: 'cout' was not declared in this scope
     cout << fixed << setprecision(6) << ans;
     ^~~~
mobile.cpp:80:5: note: suggested alternative: 'cosl'
     cout << fixed << setprecision(6) << ans;
     ^~~~
     cosl
mobile.cpp:80:22: error: 'setprecision' was not declared in this scope
     cout << fixed << setprecision(6) << ans;
                      ^~~~~~~~~~~~