답안 #916281

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
916281 2024-01-25T15:16:50 Z asdasdqwer Mobile (BOI12_mobile) C++14
8 / 100
1000 ms 64852 KB
#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];

    double l = 1;
    double r = 1e9;
    vector<bool> rem(n, false);

    while (abs(l-r) > 0.0000001) {
        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=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], 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";

        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 (int i=0;i<n;i++) {
                rem[i]=false;
            }
        }
    }

    cout<<l<<"\n";
}

Compilation message

mobile.cpp: In function 'int main()':
mobile.cpp:90: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]
   90 |             while (v.size() != n){
      |                    ~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 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
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 468 KB Output is correct
2 Correct 6 ms 604 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Incorrect 4 ms 604 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 816 KB Output is correct
2 Incorrect 14 ms 812 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 792 KB Output is correct
2 Incorrect 12 ms 812 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 796 KB Output is correct
2 Incorrect 13 ms 1056 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 113 ms 6076 KB Output is correct
2 Incorrect 333 ms 6060 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 141 ms 5964 KB Output is correct
2 Correct 109 ms 5584 KB Output is correct
3 Incorrect 102 ms 6988 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 341 ms 5988 KB Output is correct
2 Incorrect 352 ms 6360 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 347 ms 7480 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 174 ms 7572 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1039 ms 28684 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1014 ms 32844 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1094 ms 44016 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1053 ms 46032 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1079 ms 46024 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1002 ms 51140 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1030 ms 49884 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1020 ms 57256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1033 ms 57032 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1045 ms 64852 KB Time limit exceeded
2 Halted 0 ms 0 KB -