Submission #916301

# Submission time Handle Problem Language Result Execution time Memory
916301 2024-01-25T15:50:11 Z asdasdqwer Mobile (BOI12_mobile) C++14
35 / 100
1000 ms 67380 KB
#include <bits/stdc++.h>
using namespace std;

#define int int64_t
#define pii array<int,2>
#define double long double

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n,t;cin>>n>>t;
    vector<pii> v(n);
    for (auto &x:v)cin>>x[0]>>x[1];
    
    double l = 1;
    double r = 1e15;
    vector<bool> rem(n, false);
    
    while (abs(l-r) > 0.00001) {
        double m = (l+r)/2.0;
        int i=0;
        vector<array<double,2>> start;
        for (auto &x:v) {
            if ((double)abs(x[1]) >= m) {
                rem[i]=true;
            }
    
            else {
                double aa=(double)abs(x[1]);
                double dis=sqrt(m*m-aa*aa);
                array<double,2> pos1 = {x[0]-dis,x[0]+dis};
                if ((pos1[0] < 0.0 && pos1[1] < 0.0) || (pos1[0] > (double)t && pos1[1] > (double)t)) {
                    rem[i]=true;
                }
    
                else {
                    pos1[0]=max(pos1[0], (double)0.0);
                    pos1[1]=min(pos1[1], (double)t);
                    start.push_back(pos1);
                }
            }
    
            i++;
        }
    
        start.push_back({0.0, 0.0});
        start.push_back({(double)t,(double)t});
    
        sort(start.begin(),start.end());

        // cout<<m<<" "<<l<<" "<<r<<"\n";
        // for (auto &x:start) {
        //     cout<<x[0]<<" "<<x[1]<<"\n";
        // }
        // cout<<"\n";
        // for (auto &x:v) {
        //     cout<<x[0]<<" "<<x[1]<<"\n";
        // }
        // cout<<"\n\n";

    
        array<double,2> pos={0.0, 0.0};
        bool possible=true;
    
        for (auto &x:start) {
            if (x[0] <= pos[1]) {
                pos[1]=max(pos[1], x[1]);
            }
    
            else {
                possible=false;
                break;
            }
        }
    
        if (possible) {
            r=m;
            int cnt=0;
            int pt=0;
            for (int i=0;i<n;i++) {
                if (rem[i]) {
                    cnt++;
                }
                
                else if (cnt != 0) {
                    swap(v[i], v[pt]);
                }
    
                if (!rem[i]) {
                    pt++;
                }
            }
    
            n -= cnt;
    
            while (v.size() != n){
                v.pop_back();
                rem.pop_back();
            }
    
            for (int i=0;i<n;i++) {
                rem[i]=false;
            }
        }
    
        else {
            l=m;
            for (i=0;i<n;i++) {
                rem[i]=false;
            }
        }
    }
    cout<<setprecision(15);
    cout<<r<<"\n";
}

Compilation message

mobile.cpp: In function 'int main()':
mobile.cpp:97:29: warning: comparison of integer expressions of different signedness: 'std::vector<std::array<long int, 2> >::size_type' {aka 'long unsigned int'} and 'int64_t' {aka 'long int'} [-Wsign-compare]
   97 |             while (v.size() != n){
      |                    ~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory 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
# Verdict Execution time Memory Grader output
1 Correct 17 ms 716 KB Output is correct
2 Correct 21 ms 728 KB Output is correct
3 Correct 11 ms 600 KB Output is correct
4 Correct 11 ms 708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 952 KB Output is correct
2 Correct 42 ms 964 KB Output is correct
3 Correct 51 ms 952 KB Output is correct
4 Correct 27 ms 948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 1264 KB Output is correct
2 Correct 40 ms 952 KB Output is correct
3 Correct 52 ms 952 KB Output is correct
4 Correct 26 ms 1012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 948 KB Output is correct
2 Correct 40 ms 952 KB Output is correct
3 Correct 46 ms 1048 KB Output is correct
4 Correct 26 ms 960 KB Output is correct
5 Correct 33 ms 952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 585 ms 9740 KB Output is correct
2 Correct 904 ms 9420 KB Output is correct
3 Correct 541 ms 5044 KB Output is correct
4 Correct 488 ms 9248 KB Output is correct
5 Correct 428 ms 5096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 663 ms 9512 KB Output is correct
2 Correct 550 ms 9368 KB Output is correct
3 Correct 586 ms 8808 KB Output is correct
4 Correct 513 ms 9244 KB Output is correct
5 Correct 499 ms 9720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1060 ms 9388 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1033 ms 9844 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 712 ms 10204 KB Output is correct
2 Execution timed out 1051 ms 10196 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1057 ms 41196 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1060 ms 40712 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1040 ms 60728 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1014 ms 59428 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1040 ms 61528 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1050 ms 61228 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1004 ms 62916 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1040 ms 63680 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1024 ms 66652 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1100 ms 67380 KB Time limit exceeded
2 Halted 0 ms 0 KB -