Submission #657976

# Submission time Handle Problem Language Result Execution time Memory
657976 2022-11-11T19:16:30 Z chjiao Mobile (BOI12_mobile) C++14
0 / 100
716 ms 15956 KB
//Binary search the shortest length from the firehose
 
#include <bits/stdc++.h>
using namespace std;
 
#define fastio	ios_base::sync_with_stdio(false);cin.tie(0)
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
 
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORB(i,a,b) for(ll i=a;i>=b;i--)
 
#define getbit(mask,i) ((mask>>(i))&1)
#define getnum(i) (1<<(i))
 
#define endl "\n"
#define sz(x) (int)size(x)
#define mp make_pair
using ll = long long;
const ll MOD1 = 1e9+7;
const ll MOD2 = 998244353;
const ll MN = 1e5;
const ll MAX = LLONG_MAX;
double FLOAT_ERR = 1e-7;
double first_true_float(double lo, double hi, function<bool(double)> f) {
	// if none of the values in the range work, return hi + 1
	lo--;
	hi++;
	while (hi-lo > FLOAT_ERR) {
		double mid =  (lo + hi) / 2.0f;
		if (f(mid)) {
			hi = mid;
		} else {
			lo = mid;
		}
	}
	return lo;
}
 
int main() {
    fastio;
	//freopen("XXX.in","r",stdin);
	// freopen("XXX.out","w",stdout);
    int N;
    double L;
    cin >> N >> L;
    vector<pair<double,double>> input(N);
    for(int i=0; i<N; i++){
        cin >> input[i].first >> input[i].second;
    }
    sort(input.begin(), input.end());
    cout << setprecision(7)<<first_true_float(1, 1e16+1, [&](double x){
        double left = 0;
        FOR(i,0,N-1){
            if(x*x < input[i].second*input[i].second){
                continue;
            }
            double diviation = sqrt(x*x - input[i].second*input[i].second);
            if(input[i].first+diviation < left) continue;
            if((input[i].first-diviation) <= left){
                left = input[i].first+diviation;
            } else {
                return false;
            }
        }
        if(left >= L){
            return true;
        }

    }) << endl;
}

Compilation message

mobile.cpp: In lambda function:
mobile.cpp:71:5: warning: control reaches end of non-void function [-Wreturn-type]
   71 |     }) << endl;
      |     ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 340 KB Output is correct
2 Incorrect 4 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 57 ms 1492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 51 ms 1492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 58 ms 1628 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 81 ms 1876 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 70 ms 1876 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 283 ms 8148 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 325 ms 8124 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 352 ms 9684 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 394 ms 9684 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 438 ms 11220 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 448 ms 11220 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 508 ms 12756 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 548 ms 12756 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 607 ms 15956 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 716 ms 15956 KB Output isn't correct
2 Halted 0 ms 0 KB -