Submission #916314

# Submission time Handle Problem Language Result Execution time Memory
916314 2024-01-25T16:16:22 Z asdasdqwer Mobile (BOI12_mobile) C++14
50 / 100
1000 ms 83076 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];

    vector<pii> tt;
    for (auto &x:v) {
        if (!tt.size()) {
            tt.push_back(x);
        }

        else if (tt.back()[0] == x[0] && abs(tt.back()[1]) > abs(x[1])) {
            tt.pop_back();
        }
        tt.push_back(x);
    }

    v=tt;
    n=v.size();
    
    double l = 1;
    double r = 1e15;
    vector<bool> rem(n, false);
    
    while (abs(l-r) > 0.0001) {
        double m = (l+r)/2.0;
        int i=0;
        vector<array<double,2>> start;
        bool all=false;
        
        for (auto &x:v) {
            if ((double)abs(x[1]) >= m) {
                rem[i]=true;
            }

            if (rem[i]) {
                i++;
                continue;
            }
    
            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);
                    if (pos1[0] == 0.0 && pos1[1] == t) {
                        all=true;
                        break;
                    }

                    start.push_back(pos1);
                }
            }
    
            i++;
        }

        if (all) {
            r=m;
            continue;
        }
    
        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:129: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]
  129 |             while (v.size() != n){
      |                    ~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 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 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 6 ms 808 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 3 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 8 ms 1052 KB Output is correct
3 Correct 7 ms 872 KB Output is correct
4 Correct 2 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 8 ms 1052 KB Output is correct
3 Correct 8 ms 860 KB Output is correct
4 Correct 3 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 860 KB Output is correct
2 Correct 10 ms 1052 KB Output is correct
3 Correct 7 ms 848 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 78 ms 6464 KB Output is correct
2 Correct 231 ms 10084 KB Output is correct
3 Correct 156 ms 5392 KB Output is correct
4 Correct 24 ms 4560 KB Output is correct
5 Correct 7 ms 2012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 3032 KB Output is correct
2 Correct 19 ms 3956 KB Output is correct
3 Correct 21 ms 4560 KB Output is correct
4 Correct 22 ms 4560 KB Output is correct
5 Correct 23 ms 4820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 433 ms 10356 KB Output is correct
2 Correct 277 ms 11268 KB Output is correct
3 Correct 148 ms 7140 KB Output is correct
4 Correct 27 ms 5588 KB Output is correct
5 Correct 18 ms 4056 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 236 ms 11000 KB Output is correct
2 Correct 360 ms 11340 KB Output is correct
3 Correct 261 ms 10428 KB Output is correct
4 Correct 27 ms 5588 KB Output is correct
5 Correct 30 ms 5224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 211 ms 7432 KB Output is correct
2 Correct 328 ms 10856 KB Output is correct
3 Correct 318 ms 11312 KB Output is correct
4 Correct 30 ms 5588 KB Output is correct
5 Correct 24 ms 5224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1065 ms 48344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1063 ms 48928 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1061 ms 70600 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1020 ms 71132 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1045 ms 73196 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1043 ms 73896 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1032 ms 78592 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1050 ms 75932 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1080 ms 82320 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1061 ms 83076 KB Time limit exceeded
2 Halted 0 ms 0 KB -