Submission #650960

# Submission time Handle Problem Language Result Execution time Memory
650960 2022-10-16T08:19:19 Z Zflop Mobile (BOI12_mobile) C++14
100 / 100
841 ms 35404 KB
#include <bits/stdc++.h>
using namespace std;
 
/*
ID: 10002181
LANG: C++
TASK: sprime
*/ 
 
using str = string; // yay python!
using ld = long double; // or double, if TL is tight
using ll = long long;
using int64 = ll;
using db = double;
using ull = unsigned long long;
 
#define ch() getchar()
#define pc(x) putchar(x)
#define tcT template<class T
#define tcTU tcT, class U
tcT> using V = vector<T>; 
tcT, size_t SZ> using AR = array<T,SZ>; 
using vi = V<int>;
using vb = V<bool>;
using vpi = V<pair<int,int>>;
using vvi = V<vi>;
using vl = V<ll>;
using vd = V<ld>;
using vstr = V<str>;
 
#define mp make_pair
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define sor(x) sort(all(x)) 
#define rev(x) reverse(all(x))
#define sz(x) (int)(x).size()
#define AR array
 
#define F0R(i, a, b) for (int i=a; i<b;++i)
#define FOR(i, a) for (int i=0; i<a;++i)
#define FORn(i, a) for (int i=1; i<=a;++i)
#define ROF(i,a) for(int i=a-1; i >= 0;--i)
#define R0F(i,a,b) for(int i=a; i > b;--i)
#define ROFn(i,a) for(int i=a; i > 0;--i)
#define trav(i,x) for(auto& i:x)
 
// pairs
#define mp make_pair
#define f first
#define s second
 
// vectors
#define lb lower_bound
#define ub upper_bound
#define SUM(v) accumulate(all(v), 0LL)
#define MN(v) *min_element(all(v))
#define MX(v) *max_element(all(v))
#define eb emplace_back
#define ft front()
#define bk back()
#define ins insert 
#define pf push_front
#define pb push_back
#define emt empty()
#define rsz resize
 
#define pob pop_back()
#define pof pop_front()
 
#define swp(a,b) a^=b^=a^=b
 
#define ts to_string
 
#define setIO()  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
 
const ll MOD = 1e9+7;
const ll MAX = 100000000000;
const ll INF = 1e18; // not too close to LLONG_MAX
const ld PI = acos((ld)-1);
 
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
 
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1}; // for every grid problem!!
 
//INPUT
#define tcTUU tcT, class ...U
tcT> void re(complex<T>& c);
tcTU> void re(pair<T,U>& p);
tcT> void re(V<T>& v);
tcT, size_t SZ> void re(AR<T,SZ>& a);
 
tcT> void re(T& x) { cin >> x; }
void re(db& d) { str t; re(t); d = stod(t); }
void re(ld& d) { str t; re(t); d = stold(t); }
tcTUU> void re(T& t, U&... u) { re(t); re(u...); }
 
tcT> void re(complex<T>& c) { T a,b; re(a,b); c = {a,b}; }
tcTU> void re(pair<T,U>& p) { re(p.f,p.s); }
tcT> void re(V<T>& x) { trav(a,x) re(a); }
tcT> void rv(int n, V<T>& x) { x.rsz(n); re(x); }
 
//OUTPUT
namespace output {
	tcT> void prv(V<T>& x) { FOR(i,sz(x)) cout << x[i] << " \n"[i + 1 == sz(x)];}
    template<class T1, class T2> void pr(const pair<T1,T2>& x);
    tcT, size_t SZ> void pr(const array<T,SZ>& x);
    tcT> void pr(const vector<T>& x);
    tcT> void pr(const set<T>& x);
    template<class T1, class T2> void pr(const map<T1,T2>& x);
 
    tcT> void pr(const T& x) { cout << x; }
    template<class Arg, class... Args> void pr(const Arg& first, const Args&... rest) { 
        pr(first); pr(rest...); 
    }
 
    template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
        pr("{",x.f,", ",x.s,"}"); 
    }
    tcT> void prContain(const T& x) {
        pr("{");
        bool fst = 1; trav(a,x) pr(!fst?", ":"",a), fst = 0; 
        pr("}");
    }
    tcT, size_t SZ> void pr(const array<T,SZ>& x) { prContain(x); }
    tcT> void pr(const vector<T>& x) { prContain(x); }
    tcT> void pr(const set<T>& x) { prContain(x); }
    template<class T1, class T2> void pr(const map<T1,T2>& x) { prContain(x); }
    
    template<class Arg> void ps(const Arg& first) { pr(first,"\n"); } // print w/ spaces
    template<class Arg, class... Args> void ps(const Arg& first, const Args&... rest) { 
        pr(first," "); ps(rest...); 
    }
}
 
using namespace output;
 
 
void setF(string fileName = "") {
	ios_base::sync_with_stdio(0); cin.tie(0);
	if((int)fileName.size()) {
		freopen((fileName+".in").c_str(), "r", stdin);
		freopen((fileName+".out").c_str(), "w", stdout);
	}
}
 
struct DSU {
	vector<int> e;
	DSU(int N) { e = vector<int>(N, -1); }
	
	int get(int x) { return e[x] < 0 ? x : e[x] = get(e[x]); }
 
	bool same_set(int a, int b) { return get(a) == get(b); }
 
	int size(int x) { return -e[get(x)]; }
 
	bool unite(int x, int y) {  // union by size
		x = get(x), y = get(y);
		if (x == y) return false;
		if (e[x] > e[y]) swap(x, y);
		e[x] += e[y]; e[y] = x;
		return true;
	}
};
struct edge{
	int a;
	int b;
	int w;
	};
 
ll bpow(ll x, ll y){
    x %= MOD;
    ll res = 1LL;
    while(y){
        if (y & 1LL)
            res *= x;
        res %= MOD;
        x = (x*x) % MOD;
        y >>= 1LL;
    }
    return res;
}
 
ll gauss(int n){ return n*(n+1)/2; }
 
ll fact(int x){ if(x) return x * (x - 1); return 1; }
/*
 scanf("%lld", &testInteger);
 printf("%lld", testInteger);
 
 ____ ____ ____ ____ ____  ____
||f |||l |||o |||p |||p ||||y ||
||__|||__|||__|||__|||__||||__||
|/__\|/__\|/__\|/__\|/__\||/__\|
 
**/
const db MAX_ERROR = 1e-3;
void solve(){
	int N,L; cin >> N >> L;	
  	vector<pair<db,db>> A(N); re(A);
  	auto work = [&](db x){
      db st = 0;
      FOR(i,N){
        if(x >= abs(A[i].s)){
          db dist = sqrt(x * x - A[i].s * A[i].s);
          if(A[i].f - dist <= st) st = max(st,A[i].f + dist);
        }
      }
      return st >= L;
    };
  
  	db l = 0,r = 1.5e9;
  	while(r - l > MAX_ERROR){
      db mid = (l + r) / 2;
      if(work(mid)) r = mid;
      else l = mid;
    }
  	cout << fixed << setprecision(4) << l << '\n';
}
main()
{   //setIO();
	solve();
} 
// look out for out of bounds arrays
//is y a vowel? Damian:1
// <3 :L ._. <_< 
//You have no idea how high I can fly

Compilation message

mobile.cpp:222:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
  222 | main()
      | ^~~~
mobile.cpp: In function 'void setF(std::string)':
mobile.cpp:144:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  144 |   freopen((fileName+".in").c_str(), "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:145:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  145 |   freopen((fileName+".out").c_str(), "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 212 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 2 ms 308 KB Output is correct
4 Correct 3 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 340 KB Output is correct
2 Correct 4 ms 404 KB Output is correct
3 Correct 4 ms 340 KB Output is correct
4 Correct 5 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 340 KB Output is correct
2 Correct 4 ms 340 KB Output is correct
3 Correct 4 ms 412 KB Output is correct
4 Correct 5 ms 436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 352 KB Output is correct
2 Correct 4 ms 340 KB Output is correct
3 Correct 4 ms 340 KB Output is correct
4 Correct 5 ms 440 KB Output is correct
5 Correct 4 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 55 ms 1464 KB Output is correct
2 Correct 60 ms 2564 KB Output is correct
3 Correct 37 ms 1748 KB Output is correct
4 Correct 56 ms 2620 KB Output is correct
5 Correct 30 ms 1364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 1516 KB Output is correct
2 Correct 49 ms 2204 KB Output is correct
3 Correct 57 ms 2576 KB Output is correct
4 Correct 60 ms 2724 KB Output is correct
5 Correct 65 ms 3032 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 1620 KB Output is correct
2 Correct 61 ms 2736 KB Output is correct
3 Correct 57 ms 2508 KB Output is correct
4 Correct 82 ms 3752 KB Output is correct
5 Correct 55 ms 2508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 82 ms 1864 KB Output is correct
2 Correct 76 ms 3244 KB Output is correct
3 Correct 69 ms 2864 KB Output is correct
4 Correct 82 ms 3760 KB Output is correct
5 Correct 67 ms 2992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 76 ms 1856 KB Output is correct
2 Correct 78 ms 3268 KB Output is correct
3 Correct 69 ms 2884 KB Output is correct
4 Correct 80 ms 3792 KB Output is correct
5 Correct 71 ms 3128 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 311 ms 8120 KB Output is correct
2 Correct 386 ms 15780 KB Output is correct
3 Correct 377 ms 15372 KB Output is correct
4 Correct 422 ms 17712 KB Output is correct
5 Correct 347 ms 14888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 390 ms 8116 KB Output is correct
2 Correct 396 ms 14732 KB Output is correct
3 Correct 337 ms 13864 KB Output is correct
4 Correct 515 ms 17356 KB Output is correct
5 Correct 354 ms 15412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 382 ms 9692 KB Output is correct
2 Correct 472 ms 18896 KB Output is correct
3 Correct 453 ms 18244 KB Output is correct
4 Correct 509 ms 21440 KB Output is correct
5 Correct 420 ms 17656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 486 ms 9692 KB Output is correct
2 Correct 479 ms 17484 KB Output is correct
3 Correct 405 ms 16460 KB Output is correct
4 Correct 506 ms 21404 KB Output is correct
5 Correct 440 ms 18512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 454 ms 11220 KB Output is correct
2 Correct 550 ms 21992 KB Output is correct
3 Correct 523 ms 21356 KB Output is correct
4 Correct 578 ms 24652 KB Output is correct
5 Correct 478 ms 20192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 562 ms 11252 KB Output is correct
2 Correct 548 ms 20448 KB Output is correct
3 Correct 480 ms 19552 KB Output is correct
4 Correct 572 ms 24548 KB Output is correct
5 Correct 512 ms 21344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 502 ms 12944 KB Output is correct
2 Correct 632 ms 25212 KB Output is correct
3 Correct 610 ms 24328 KB Output is correct
4 Correct 703 ms 28620 KB Output is correct
5 Correct 595 ms 23960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 660 ms 12884 KB Output is correct
2 Correct 653 ms 23368 KB Output is correct
3 Correct 570 ms 22272 KB Output is correct
4 Correct 654 ms 28164 KB Output is correct
5 Correct 573 ms 24324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 635 ms 16084 KB Output is correct
2 Correct 763 ms 31468 KB Output is correct
3 Correct 762 ms 30484 KB Output is correct
4 Correct 841 ms 35008 KB Output is correct
5 Correct 700 ms 29524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 802 ms 16076 KB Output is correct
2 Correct 763 ms 29160 KB Output is correct
3 Correct 709 ms 28236 KB Output is correct
4 Correct 827 ms 35404 KB Output is correct
5 Correct 727 ms 30696 KB Output is correct