답안 #970756

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
970756 2024-04-27T08:11:39 Z hihihihaw Mobile (BOI12_mobile) C++17
50 / 100
1000 ms 82112 KB
#pragma GCC optimize("O3,unroll-loops")    
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define pii pair<int,int>
#define sz(v) (int)v.size()
#define fi first
#define se second
#define INF 1223372036854775807
#define MOD 1000000007
#define cint(x) int x;cin>>x;
#define cinarr(a,n) int a[n];for (int i=0;i<n;i++) cin>>a[i];
#define coutarr(a) for (auto d:a)cout<<d<<" "; cout<<endl;
#define coutarrD(a) for (auto d:a) cout<<d.fi<<","<<d.se<<" "; cout<<endl;
#define AYBERK_SARICA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
#define ld long double
#define mid (start+end)/2

int t=1;
int interactive=0;
int usaco=0;
int testCase=0;
int n,k;
pair<ld,ld> v[1000023];
bool f(ld x){
    vector<pair<ld,ld>> z;
    for (int i=0;i<n;i++){
        if (x*x-v[i].se*v[i].se>0){
            ld y=sqrt(x*x-v[i].se*v[i].se);
            if (v[i].fi+y<0 || v[i].fi-y>k) continue;
            z.pb({max(v[i].fi-y,(ld)0),min(v[i].fi+y,(ld)k)});
        }
    }
    sort(z.begin(),z.end());
    ld b=0;
    for (int i=0;i<sz(z);i++){
        if (z[i].fi>b){
            return false;
        }
        else{
            b=max(z[i].se,b);
        }
    }
    if (b!=k) return false;
    return true;
}

void solve(){
    cin>>n>>k;
    for (int i=0;i<n;i++){
        ld x,y;
        cin>>x>>y;
        v[i]={x,y};
    }
    ld l=0,r=2000000000;
    int y=42;
    while (y--){
        ld m=(l+r)/2;
        if (f(m)) r=m;
        else l=m;
    }
    cout<<setprecision(15)<<l<<endl;
    

    
    
    

    
    


    
    
    
    
    

    

    
    

    

    
}



 
 
    
 
 
 
 
 
int32_t main(){
    AYBERK_SARICA;
    if (usaco){
        freopen("socdist.in", "r", stdin);
        freopen("socdist.out", "w", stdout);
    }
    if (!interactive){
    #ifdef Local
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        //freopen("wormsort.out", "w", stdout);
    #endif
    }
    if (t==1) solve();
    else{
        cin>>t;
        while (t--){testCase++;solve();}
    }
    
        
    return 0;
}

Compilation message

mobile.cpp: In function 'int32_t main()':
mobile.cpp:105:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  105 |         freopen("socdist.in", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:106:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  106 |         freopen("socdist.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 600 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 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 9 ms 784 KB Output is correct
2 Correct 11 ms 780 KB Output is correct
3 Correct 6 ms 600 KB Output is correct
4 Correct 4 ms 712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 1124 KB Output is correct
2 Correct 19 ms 1204 KB Output is correct
3 Correct 25 ms 1040 KB Output is correct
4 Correct 11 ms 1064 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 1056 KB Output is correct
2 Correct 23 ms 1432 KB Output is correct
3 Correct 26 ms 1040 KB Output is correct
4 Correct 11 ms 1028 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 1044 KB Output is correct
2 Correct 19 ms 1056 KB Output is correct
3 Correct 28 ms 1060 KB Output is correct
4 Correct 10 ms 1060 KB Output is correct
5 Correct 17 ms 1044 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 239 ms 11808 KB Output is correct
2 Correct 461 ms 12708 KB Output is correct
3 Correct 310 ms 6780 KB Output is correct
4 Correct 166 ms 11548 KB Output is correct
5 Correct 200 ms 6328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 299 ms 12632 KB Output is correct
2 Correct 229 ms 9952 KB Output is correct
3 Correct 237 ms 12584 KB Output is correct
4 Correct 180 ms 12316 KB Output is correct
5 Correct 149 ms 13032 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 520 ms 11804 KB Output is correct
2 Correct 497 ms 12780 KB Output is correct
3 Correct 693 ms 12392 KB Output is correct
4 Correct 118 ms 11956 KB Output is correct
5 Correct 313 ms 11640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 473 ms 12816 KB Output is correct
2 Correct 669 ms 12580 KB Output is correct
3 Correct 831 ms 13256 KB Output is correct
4 Correct 115 ms 12044 KB Output is correct
5 Correct 282 ms 11948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 220 ms 12084 KB Output is correct
2 Correct 616 ms 11992 KB Output is correct
3 Correct 815 ms 12284 KB Output is correct
4 Correct 121 ms 13064 KB Output is correct
5 Correct 297 ms 11976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1051 ms 49332 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1022 ms 50004 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1031 ms 72280 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1084 ms 72500 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1034 ms 73548 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1050 ms 72736 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1058 ms 77920 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1022 ms 78176 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1055 ms 82112 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1022 ms 81796 KB Time limit exceeded
2 Halted 0 ms 0 KB -