답안 #916403

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
916403 2024-01-25T19:43:45 Z asdasdqwer Mobile (BOI12_mobile) C++14
60 / 100
1000 ms 91268 KB
#pragma GCC optimize("O3")

#include <bits/stdc++.h>
using namespace std;

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


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();

    long double l = 1;
    long double r = 1e10;

    cout<<setprecision(15);

    for (auto &x:v) {
        r = min(r, (long double)max(sqrt(x[0]*x[0] + x[1]*x[1]), sqrt((x[0]-t)*(x[0]-t) + x[1]*x[1])));
    }

    // cout<<r<<"\n";

    vector<bool> rem(n, false);
    
    while (abs(l-r) > 0.0001) {
        long double m = (l+r)/2.0;
        int i=0;
        vector<array<long 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 {
                long double aa=(double)abs(x[1]);
                long double dis=sqrt(m*m-aa*aa);
                array<long 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], (long double)0.0);
                    pos1[1]=min(pos1[1], (long double)t);
                    if (pos1[0] == 0.0 && pos1[1] == t) {
                        all=true;
                        break;
                    }

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

        if (all) {
            r=m;
            continue;
        }

        bool possible=true;

        double e=0.0;

        for (auto &x:start) {
            if (x[0] <= e && x[1] > e) {
                e=x[1];
            }
        }

        if (e<t) possible=false;
    
        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<<r<<"\n";
}

Compilation message

mobile.cpp: In function 'int main()':
mobile.cpp:122: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]
  122 |             while (v.size() != n){
      |                    ~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 460 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 3 ms 808 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 8 ms 1232 KB Output is correct
3 Correct 4 ms 916 KB Output is correct
4 Correct 2 ms 608 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 8 ms 1112 KB Output is correct
3 Correct 3 ms 908 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 860 KB Output is correct
2 Correct 8 ms 1244 KB Output is correct
3 Correct 4 ms 916 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 6708 KB Output is correct
2 Correct 138 ms 11556 KB Output is correct
3 Correct 57 ms 6076 KB Output is correct
4 Correct 16 ms 4560 KB Output is correct
5 Correct 7 ms 2268 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 3548 KB Output is correct
2 Correct 13 ms 3536 KB Output is correct
3 Correct 15 ms 4524 KB Output is correct
4 Correct 18 ms 4808 KB Output is correct
5 Correct 17 ms 5080 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 118 ms 11200 KB Output is correct
2 Correct 134 ms 10944 KB Output is correct
3 Correct 91 ms 8204 KB Output is correct
4 Correct 22 ms 5580 KB Output is correct
5 Correct 15 ms 4044 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 185 ms 12216 KB Output is correct
2 Correct 175 ms 12896 KB Output is correct
3 Correct 108 ms 12200 KB Output is correct
4 Correct 22 ms 5580 KB Output is correct
5 Correct 18 ms 5332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 89 ms 8624 KB Output is correct
2 Correct 169 ms 12164 KB Output is correct
3 Correct 99 ms 10756 KB Output is correct
4 Correct 22 ms 5780 KB Output is correct
5 Correct 18 ms 5332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 827 ms 50832 KB Output is correct
2 Correct 848 ms 52920 KB Output is correct
3 Correct 747 ms 52160 KB Output is correct
4 Correct 101 ms 29120 KB Output is correct
5 Correct 99 ms 25628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 948 ms 52952 KB Output is correct
2 Correct 237 ms 44336 KB Output is correct
3 Correct 560 ms 48172 KB Output is correct
4 Correct 98 ms 28080 KB Output is correct
5 Correct 88 ms 27584 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1095 ms 73844 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1052 ms 75412 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1024 ms 76340 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1095 ms 80872 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1004 ms 82684 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1092 ms 83540 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1070 ms 87948 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1028 ms 91268 KB Time limit exceeded
2 Halted 0 ms 0 KB -