Submission #470002

# Submission time Handle Problem Language Result Execution time Memory
470002 2021-09-02T14:59:13 Z Shogun3103 Mobile (BOI12_mobile) C++17
12 / 100
709 ms 19012 KB
#include <bits/stdc++.h>
 
using namespace std;

void setIO(string fileName = ""){
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);        
    if(fileName.length()){
        freopen((fileName+".in").c_str(), "r", stdin);
        freopen((fileName+".out").c_str(), "w", stdout);
    }
}

#define ll long long
#define ld long double
#define FOR(i,a,b) for(__typeof(b) i=a; i<=b; i++)
#define FOD(i,a,b) for(__typeof(b) i=b; i>=a; i--)
#define EACH(u, v) for(auto& u : v)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define ii pair<int,int>
#define iii pair<int,ii>
#define ld2 pair<ld, ld>
#define ll2 pair<ll, ll>
#define X first
#define Y second
#define ed "\n"
#define sp " "
const int oo = 1e9 + 7;
const int N = 1e6 + 10;

int n, len;
ii a[N];
ld cur;

bool calc(ld x)
{   
    FOR(i, 1, n) {
        ld delta = sqrt(x * x - a[i].Y * a[i].Y);
        ld x = a[i].X - delta, y = a[i].X + delta;
        if(x <= cur) cur = max(cur, y);
    }   
    return cur >= len;
}

void solve()
{
    cin >> n >> len;
    FOR(i, 1, n) cin >> a[i].X >> a[i].Y;

    ld l = 1, r = 1.5e9;
    while(l <= r) {
        ld m = (l + r) * 0.5;
        cur = 0;
        if(calc(m)) {
            r = m - 0.0001;
        } else {
            l = m + 0.0001;
        }
    }
    cout << fixed << setprecision(6) << r; 
}   

int main()
{ 
    setIO("");
    int t; 
    t = 1;
    //cin >> t;
    FOR(i, 1, t) {
        solve();
    }
    return 0;
}

Compilation message

mobile.cpp: In function 'void setIO(std::string)':
mobile.cpp:8:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |         freopen((fileName+".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:9:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |         freopen((fileName+".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 2 ms 352 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 360 KB Output is correct
2 Correct 4 ms 332 KB Output is correct
3 Correct 4 ms 460 KB Output is correct
4 Incorrect 6 ms 332 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 332 KB Output is correct
2 Correct 4 ms 328 KB Output is correct
3 Correct 4 ms 328 KB Output is correct
4 Incorrect 6 ms 332 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 408 KB Output is correct
2 Correct 5 ms 332 KB Output is correct
3 Correct 4 ms 332 KB Output is correct
4 Incorrect 6 ms 332 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 74 ms 1680 KB Output is correct
2 Incorrect 52 ms 1868 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 73 ms 1612 KB Output is correct
2 Correct 70 ms 1672 KB Output is correct
3 Incorrect 87 ms 2052 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 62 ms 1652 KB Output is correct
2 Incorrect 55 ms 2120 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 68 ms 2640 KB Output is correct
2 Incorrect 64 ms 2488 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 76 ms 2500 KB Output is correct
2 Incorrect 65 ms 2492 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 365 ms 8500 KB Output is correct
2 Incorrect 317 ms 11976 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 349 ms 12516 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 449 ms 10164 KB Output is correct
2 Incorrect 404 ms 13252 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 409 ms 13292 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 499 ms 11716 KB Output is correct
2 Incorrect 462 ms 14104 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 476 ms 14148 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 564 ms 13480 KB Output is correct
2 Incorrect 559 ms 19012 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 553 ms 14916 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 709 ms 16448 KB Output is correct
2 Incorrect 672 ms 16376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 661 ms 14308 KB Output isn't correct
2 Halted 0 ms 0 KB -