Submission #970762

# Submission time Handle Problem Language Result Execution time Memory
970762 2024-04-27T08:23:48 Z hihihihaw Mobile (BOI12_mobile) C++17
50 / 100
1000 ms 62892 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){
    pair<ld,ld> z[n]={};
    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[i]={max(v[i].fi-y,(ld)0),min(v[i].fi+y,(ld)k)};
        }
    }
    sort(z,z+n);
    ld b=0;
    for (int i=0;i<n;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);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 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
# Verdict Execution time Memory Grader output
1 Correct 1 ms 356 KB Output is correct
2 Correct 1 ms 456 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 16 ms 628 KB Output is correct
2 Correct 10 ms 604 KB Output is correct
3 Correct 9 ms 584 KB Output is correct
4 Correct 11 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 604 KB Output is correct
2 Correct 19 ms 772 KB Output is correct
3 Correct 27 ms 600 KB Output is correct
4 Correct 25 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 604 KB Output is correct
2 Correct 16 ms 604 KB Output is correct
3 Correct 25 ms 768 KB Output is correct
4 Correct 25 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 604 KB Output is correct
2 Correct 16 ms 600 KB Output is correct
3 Correct 29 ms 604 KB Output is correct
4 Correct 25 ms 600 KB Output is correct
5 Correct 25 ms 804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 478 ms 7256 KB Output is correct
2 Correct 398 ms 7112 KB Output is correct
3 Correct 300 ms 4184 KB Output is correct
4 Correct 484 ms 7068 KB Output is correct
5 Correct 303 ms 4220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 491 ms 7156 KB Output is correct
2 Correct 462 ms 4860 KB Output is correct
3 Correct 512 ms 7252 KB Output is correct
4 Correct 496 ms 7192 KB Output is correct
5 Correct 561 ms 7420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 445 ms 7460 KB Output is correct
2 Correct 455 ms 7284 KB Output is correct
3 Correct 591 ms 7360 KB Output is correct
4 Correct 634 ms 8016 KB Output is correct
5 Correct 560 ms 7492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 398 ms 7760 KB Output is correct
2 Correct 563 ms 7844 KB Output is correct
3 Correct 721 ms 7844 KB Output is correct
4 Correct 623 ms 7844 KB Output is correct
5 Correct 631 ms 8064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 708 ms 7844 KB Output is correct
2 Correct 579 ms 8048 KB Output is correct
3 Correct 715 ms 7840 KB Output is correct
4 Correct 630 ms 7844 KB Output is correct
5 Correct 631 ms 7844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1054 ms 32796 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1065 ms 32652 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1036 ms 39812 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1043 ms 39824 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1008 ms 45140 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1057 ms 45068 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1034 ms 52308 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1099 ms 52308 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1057 ms 62892 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1030 ms 62884 KB Time limit exceeded
2 Halted 0 ms 0 KB -