Submission #672921

# Submission time Handle Problem Language Result Execution time Memory
672921 2022-12-19T03:11:19 Z hadnew Mobile (BOI12_mobile) C++17
0 / 100
1000 ms 40376 KB
#include <bits/stdc++.h>
using namespace std;

vector<array<int,2>> points;
int n, l;

auto comp = [](pair<double,double> a, pair<double,double> b){
    return (a.first != b.first) ? a.first < b.first : a.second < b.second;
};

bool test(double r)
{
    vector<pair<double,double>> v;
    
    for (int i = 0; i < n; i++)
    {
        double h = points[i][0]; // x val of center
        double k = points[i][1];
        if (r <= k)
        {
            continue;
        }
        double len = sqrt(pow(r,2)-pow(k,2));
        //cout << "LEG LENGTH: "<<len<<endl;
        pair<double,double> p = make_pair(h-len, h+len);
        v.push_back(p);
    }
    sort(v.begin(), v.end(), comp); 
    /*
    for (auto pii : v)
    {
        cout << pii.first << " - " << pii.second << endl;
    }
    */
    // pairs all sorted
    double ma = -1;
    for (int i = 0; i < v.size(); i++)
    {
        if (v[i].second < v[i+1].first)
        {
            return false;
        }
        ma = max(max(v[i].second,v[i+1].second),ma);
    }
    return v[0].first <= 0 && ma >= l;
}

int main()
{
    cin >> n >> l;
    for (int i = 0; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        points.push_back(array<int,2>{{a,b}});
    }
    auto comp = [](array<int,2> a, array<int,2> b) {
        return a[0] < b[0];
    };
    sort(points.begin(), points.end(), comp);
    //cout << "ANS: " << ((test(5)) ? "WORKS" : "DOESNT WORK") << endl;
    double lo = 0;
    double hi = 1500000000; // longest r needed is 10e9 sqrt2
    while (lo < hi) // better precision than needed just to be safe
    {
        double mid = lo+(hi-lo)/2;
        if (test(mid))
        {
            hi = mid;
        }
        else
        {
            lo = mid+0.00001;
        }
    }
    cout << lo << endl;
}

Compilation message

mobile.cpp: In function 'bool test(double)':
mobile.cpp:37:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<double, double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for (int i = 0; i < v.size(); i++)
      |                     ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1083 ms 328 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 560 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 552 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 10 ms 864 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 133 ms 4168 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 393 ms 4264 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 371 ms 4448 KB Output is correct
2 Incorrect 383 ms 5596 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 389 ms 4728 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1097 ms 4784 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1079 ms 20416 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1089 ms 20420 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1095 ms 31092 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1098 ms 30940 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1097 ms 33192 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1096 ms 33188 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1100 ms 35572 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1093 ms 35784 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1095 ms 40376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1095 ms 40176 KB Time limit exceeded
2 Halted 0 ms 0 KB -