답안 #985949

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
985949 2024-05-19T11:48:31 Z anurag203 Mobile (BOI12_mobile) C++17
100 / 100
556 ms 35456 KB
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define mod 1000000007
#define inf 1e18
#define endl "\n"
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ff first
#define ss second
#define PI 3.141592653589793238462
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rep(i, init, n) for (int i = init; i < (int)n; i++)
#define rev(i, n, init) for (int i = (int)n; i >= init; i--)
#define V vector<int>
#define VV vector<V>
#define Vll vector<ll>
#define VVll vector<Vll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define Vpii vector<pii>
#define VVpii vector<Vpii>
#define Vpll vector<pll> 
#define VVpll vector<Vpll>
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; // find_by_order, order_of_key

#ifndef Anurag203
#define debug(x) cerr << #x <<" "; _print(x); cerr << endl;
#else
#define debug(x)
#endif

void _print(ll t) {cerr << t;}
void _print(int t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(double t) {cerr << t;}

template <class T, class vv> void _print(pair <T, vv> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class vv> void _print(map <T, vv> v);
template <class T> void _print(multiset <T> v);
template <class T> void _print(ordered_set <T> v);
template <class T, class vv> void _print(pair <T, vv> p) {cerr << "{"; _print(p.ff); cerr << ","; _print(p.ss); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class vv> void _print(map <T, vv> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(ordered_set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
/*----------------------------------------------------------------------------------------------------------------------------------------------------*/
ll gcd(ll a, ll b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
ll powe(ll x,ll y, ll p=mod){ll res = 1; x = x % p;while (y > 0){ if (y & 1) res = (res * x) % p;y = y >> 1; x = (x * x) % p;} return res;}
bool revsort(ll a, ll b) {return a > b;}
ll inverse_modulo(ll a, ll p = mod) {return powe(a, p - 2, p);}
Vll fact; void fill_fact(ll p = mod) {fact.resize(200005, 1); rep(i, 1, 200005) { fact[i] = (fact[i - 1] * i) % p; }}
ll C(ll n,ll r,ll p=mod) {return ((fact[n]*inverse_modulo(fact[n-r]))%mod*inverse_modulo(fact[r]))%mod;}
void google(int t) {cout << "Case #" << t << ": ";}
Vll spf; void sieve(ll n = 200005) {spf.resize(n + 1, 1); ll i, j; for (ll i = 2; i <= n; i++) {if (spf[i] == 1) {spf[i] = i; for (j = i * i; j <= n; j += i){if (spf[j] == 1) spf[j] = i;}}}}
bool is_prime(ll x) {return (spf[x] == x);}
Vpll prime_factors(ll x) {Vpll ans; while (x != 1) {ll a = spf[x], cnt = 0; while (x % a == 0) x /= a, cnt++; ans.pb({a, cnt});}return ans;}
/*----------------------------------------------------------------------------------------------------------------------------------------------------*/
double n, l;
bool check(double mid, vector<pair<double, double>> &a)
{
    double mx = 0;
    for (auto e : a)
    {
        double x = (mid * mid) - (e.ss * e.ss);
        if (x < 0) continue;
        x = sqrt(x);
        if (e.ff - x <= mx) mx = max(mx, e.ff + x);
    }
    return mx >= l;
}
void solve()
{
    cin >> n >> l;
    vector<pair<double, double>> a(n);
    rep(i, 0, n) cin >> a[i].first >> a[i].second;

    double l = 0, r = 1e10, ans;
    rep(i, 0, 60)
    {
        double mid = (l + r) / 2;
        if (check(mid, a))
        {
            ans = mid;
            r = mid;
        }
        else l = mid;
    }
    cout << fixed << setprecision(6) << ans << endl;
}
int main() {
#ifndef Anurag203
    freopen("Error.txt", "w", stderr);
#endif
    fastio();
    // freopen("output.in", "r", stdin);
    // freopen("output.out", "w", stdout);

    int tt = 1;
    // cin>>tt;
    rep(ii, 1, tt + 1)
    {
        // google(ii);
        solve();
    }       
    return 0;
}

Compilation message

mobile.cpp: In function 'void sieve(long long int)':
mobile.cpp:66:62: warning: unused variable 'i' [-Wunused-variable]
   66 | Vll spf; void sieve(ll n = 200005) {spf.resize(n + 1, 1); ll i, j; for (ll i = 2; i <= n; i++) {if (spf[i] == 1) {spf[i] = i; for (j = i * i; j <= n; j += i){if (spf[j] == 1) spf[j] = i;}}}}
      |                                                              ^
mobile.cpp: In function 'int main()':
mobile.cpp:104:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  104 |     freopen("Error.txt", "w", stderr);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 360 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 344 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 3 ms 604 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 3 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 348 KB Output is correct
2 Correct 3 ms 604 KB Output is correct
3 Correct 3 ms 572 KB Output is correct
4 Correct 3 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 536 KB Output is correct
2 Correct 3 ms 604 KB Output is correct
3 Correct 3 ms 344 KB Output is correct
4 Correct 3 ms 604 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 1628 KB Output is correct
2 Correct 39 ms 2556 KB Output is correct
3 Correct 24 ms 1880 KB Output is correct
4 Correct 43 ms 2764 KB Output is correct
5 Correct 19 ms 1628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 1628 KB Output is correct
2 Correct 30 ms 2136 KB Output is correct
3 Correct 35 ms 2652 KB Output is correct
4 Correct 34 ms 2716 KB Output is correct
5 Correct 38 ms 3232 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 1624 KB Output is correct
2 Correct 40 ms 1628 KB Output is correct
3 Correct 38 ms 1628 KB Output is correct
4 Correct 44 ms 1884 KB Output is correct
5 Correct 36 ms 2740 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 50 ms 1884 KB Output is correct
2 Correct 49 ms 1884 KB Output is correct
3 Correct 44 ms 1884 KB Output is correct
4 Correct 45 ms 1880 KB Output is correct
5 Correct 46 ms 3156 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 50 ms 1880 KB Output is correct
2 Correct 49 ms 3420 KB Output is correct
3 Correct 45 ms 3168 KB Output is correct
4 Correct 45 ms 3804 KB Output is correct
5 Correct 42 ms 3152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 221 ms 8284 KB Output is correct
2 Correct 250 ms 15948 KB Output is correct
3 Correct 245 ms 15436 KB Output is correct
4 Correct 221 ms 17744 KB Output is correct
5 Correct 212 ms 15056 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 252 ms 8280 KB Output is correct
2 Correct 306 ms 14672 KB Output is correct
3 Correct 220 ms 13908 KB Output is correct
4 Correct 218 ms 17488 KB Output is correct
5 Correct 209 ms 15468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 266 ms 9820 KB Output is correct
2 Correct 298 ms 19300 KB Output is correct
3 Correct 290 ms 18516 KB Output is correct
4 Correct 264 ms 21588 KB Output is correct
5 Correct 258 ms 17636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 297 ms 9816 KB Output is correct
2 Correct 352 ms 17748 KB Output is correct
3 Correct 274 ms 16632 KB Output is correct
4 Correct 264 ms 21480 KB Output is correct
5 Correct 249 ms 18404 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 310 ms 11352 KB Output is correct
2 Correct 344 ms 22104 KB Output is correct
3 Correct 338 ms 21520 KB Output is correct
4 Correct 306 ms 24916 KB Output is correct
5 Correct 288 ms 20368 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 342 ms 11356 KB Output is correct
2 Correct 392 ms 20568 KB Output is correct
3 Correct 309 ms 19796 KB Output is correct
4 Correct 310 ms 24592 KB Output is correct
5 Correct 288 ms 21524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 355 ms 12888 KB Output is correct
2 Correct 394 ms 25380 KB Output is correct
3 Correct 392 ms 24408 KB Output is correct
4 Correct 355 ms 28512 KB Output is correct
5 Correct 339 ms 23984 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 386 ms 12888 KB Output is correct
2 Correct 453 ms 23384 KB Output is correct
3 Correct 358 ms 22356 KB Output is correct
4 Correct 365 ms 28380 KB Output is correct
5 Correct 334 ms 24400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 423 ms 15964 KB Output is correct
2 Correct 507 ms 31484 KB Output is correct
3 Correct 472 ms 30548 KB Output is correct
4 Correct 458 ms 35288 KB Output is correct
5 Correct 431 ms 29544 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 502 ms 15960 KB Output is correct
2 Correct 556 ms 29408 KB Output is correct
3 Correct 455 ms 28404 KB Output is correct
4 Correct 451 ms 35456 KB Output is correct
5 Correct 437 ms 31064 KB Output is correct