답안 #970747

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
970747 2024-04-27T08:03:11 Z hihihihaw Mobile (BOI12_mobile) C++17
45 / 100
1000 ms 84380 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;
vector<pair<ld,ld>> v;
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.pb({x,y});
    }
    ld l=0,r=2000000000;
    int y=50;
    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 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 1 ms 344 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 8 ms 780 KB Output is correct
2 Correct 11 ms 784 KB Output is correct
3 Correct 6 ms 604 KB Output is correct
4 Correct 5 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 1104 KB Output is correct
2 Correct 22 ms 1048 KB Output is correct
3 Correct 30 ms 1048 KB Output is correct
4 Correct 12 ms 1044 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 1048 KB Output is correct
2 Correct 22 ms 1048 KB Output is correct
3 Correct 30 ms 1052 KB Output is correct
4 Correct 11 ms 1068 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 1020 KB Output is correct
2 Correct 22 ms 1056 KB Output is correct
3 Correct 33 ms 1104 KB Output is correct
4 Correct 10 ms 1044 KB Output is correct
5 Correct 17 ms 1024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 251 ms 12484 KB Output is correct
2 Correct 553 ms 11552 KB Output is correct
3 Correct 364 ms 5876 KB Output is correct
4 Correct 178 ms 11972 KB Output is correct
5 Correct 206 ms 5708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 299 ms 10120 KB Output is correct
2 Correct 241 ms 10740 KB Output is correct
3 Correct 238 ms 11548 KB Output is correct
4 Correct 186 ms 11172 KB Output is correct
5 Correct 156 ms 10080 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 586 ms 10300 KB Output is correct
2 Correct 583 ms 10668 KB Output is correct
3 Correct 812 ms 12780 KB Output is correct
4 Correct 121 ms 11692 KB Output is correct
5 Correct 309 ms 12240 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 539 ms 12008 KB Output is correct
2 Correct 716 ms 14032 KB Output is correct
3 Execution timed out 1006 ms 13512 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 245 ms 11364 KB Output is correct
2 Correct 723 ms 11160 KB Output is correct
3 Correct 996 ms 12060 KB Output is correct
4 Correct 121 ms 13520 KB Output is correct
5 Correct 291 ms 12776 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1088 ms 48192 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1028 ms 48820 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1028 ms 71584 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1035 ms 71244 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1025 ms 72444 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1037 ms 72816 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1073 ms 77340 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1032 ms 77496 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1045 ms 84380 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1054 ms 82796 KB Time limit exceeded
2 Halted 0 ms 0 KB -