Submission #1101195

# Submission time Handle Problem Language Result Execution time Memory
1101195 2024-10-15T17:49:16 Z zyadhany Mobile (BOI12_mobile) C++17
0 / 100
1000 ms 67376 KB
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>

#define ll long long
#define ld long double
#define pl pair<ll, ll>
#define vi vector<ll>
#define vii vector<vi>
#define vc vector<char>
#define vcc vector<vc>
#define vp vector<pl>
#define mi map<ll,ll>
#define mc map<char,ll>
#define sortx(X) sort(X.begin(),X.end());
#define all(X) X.begin(),X.end()
#define ln '\n'
#define YES {cout << "YES\n"; return;}
#define NO {cout << "NO\n"; return;}
#define MUN {cout << "-1\n"; return;}

const int MODE = 1e9 + 7;

using namespace std;


void solve(int tc) {
    ll n, len;

    cin >> n >> len;

    vp X(n);
    for (int i = 0; i < n; i++)
        cin >> X[i].first >> X[i].second;    

    ld l = 0, r = 1e12;
    ld err = 1e-6;
    while (r - l > err)
    {
        ld mid = (l + r) / 2;
        bool isit = 0;

        ll a, b; a = b = 0;

        vector<pair<ld, ld>> Z;

        for (int i = 0; i < n; i++)
        {
            if (X[i].second > mid) continue;

            ld dis2 = mid * mid;
            ld y2 = X[i].second * X[i].second;
            ld diff = sqrtl(dis2 - y2);

            ld a = X[i].first - diff;
            ld b = X[i].first + diff;
            
            Z.push_back({a, b});
        }
        
        sortx(Z);
        for (int i = 1; i < Z.size(); i++)
        {
            if (Z[i].first > Z[i - 1].second) isit = 1;
            Z[i].second = max(Z[i].second, Z[i - 1].second);
        }
        if (Z.empty() || Z[0].first > 0 || Z.back().second < len) isit = 1;

        if (isit) l = mid;
        else r = mid - err;
    }
    
    cout << fixed << setprecision(6) << l << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    int size = 1;

    //freopen("loan.in", "r", stdin);
    //freopen("loan.out", "w", stdout);
    
    //cin >> size;
    for (int i = 1; i <= size; i++) solve(i);
}

Compilation message

mobile.cpp: In function 'void solve(int)':
mobile.cpp:63:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long double, long double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |         for (int i = 1; i < Z.size(); i++)
      |                         ~~^~~~~~~~~~
mobile.cpp:44:12: warning: variable 'a' set but not used [-Wunused-but-set-variable]
   44 |         ll a, b; a = b = 0;
      |            ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 720 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 952 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 940 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 30 ms 960 KB Output is correct
2 Correct 32 ms 1152 KB Output is correct
3 Correct 37 ms 940 KB Output is correct
4 Incorrect 31 ms 960 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 333 ms 9940 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 727 ms 9896 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 638 ms 9408 KB Output is correct
2 Correct 796 ms 9196 KB Output is correct
3 Correct 925 ms 8968 KB Output is correct
4 Execution timed out 1055 ms 9344 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 736 ms 9304 KB Output is correct
2 Correct 946 ms 10108 KB Output is correct
3 Execution timed out 1062 ms 9356 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 637 ms 9268 KB Output is correct
2 Correct 804 ms 10340 KB Output is correct
3 Execution timed out 1061 ms 9432 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1062 ms 40368 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1069 ms 41204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1033 ms 61152 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1035 ms 61132 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1054 ms 62708 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1051 ms 62756 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1055 ms 64272 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1063 ms 64268 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1045 ms 67376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1055 ms 67336 KB Time limit exceeded
2 Halted 0 ms 0 KB -