Submission #417544

# Submission time Handle Problem Language Result Execution time Memory
417544 2021-06-03T22:23:42 Z jackkkk Mobile (BOI12_mobile) C++11
4 / 100
1000 ms 48092 KB
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <array>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <list>
#include <float.h>
#include <climits>
using namespace std;

void quit(){
    cout.flush();
    exit(0);
}

int n, l;
vector <pair<double, double>> towers;
bool good(double dist){
    vector <pair<double ,double>> intervals;
    //get_intervals
    for(const auto &tower : towers){
        if(abs(tower.second)>dist){
            continue;
        }
        double range = sqrt((dist*dist)-(tower.second*tower.second));
        intervals.emplace_back(tower.first-range, tower.first+range);
    }
    sort(intervals.begin(), intervals.end());
	
    double curr_max = intervals[0].second;
    double s = intervals[0].first, f = intervals[0].second;
	intervals.emplace_back(1e50,1e50); //so that it iterates the last one
    for(size_t i = 1; i < intervals.size(); i++){
        if(f<intervals[i].first){
            if(s<=0 && f>=l){
				return true;
			}
			s=intervals[i].first;
			f=intervals[i].second;
        }
		else{
        	f=max(f, intervals[i].second);
		}
    }
    return false;
}
int main() {
	//freopen("qwer.in", "r", stdin);
	//freopen("qwer.out", "w", stdout);
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> l;
	towers.resize(n);
	for(int i = 0; i < n; i++){
	    cin >> towers[i].first >> towers[i].second;
	}
	
	double s = 0, e = 1e13, mid;
    while(e-s>0.001){
        mid = (s+e)/2;
        if(good(mid)){
            e=mid;
        }
        else{
            s=mid;
        }
    }
    cout << e << "\n";
	
	
	quit();
}

Compilation message

mobile.cpp: In function 'bool good(double)':
mobile.cpp:39:12: warning: unused variable 'curr_max' [-Wunused-variable]
   39 |     double curr_max = intervals[0].second;
      |            ^~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Runtime error 1 ms 460 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 460 KB Output is correct
2 Runtime error 6 ms 712 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 604 KB Output is correct
2 Incorrect 17 ms 680 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 604 KB Output is correct
2 Incorrect 16 ms 668 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 10 ms 884 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 178 ms 4776 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 229 ms 4976 KB Output is correct
2 Correct 202 ms 5440 KB Output is correct
3 Incorrect 212 ms 5984 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 293 ms 5188 KB Output is correct
2 Incorrect 370 ms 4988 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 391 ms 5564 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 335 ms 5536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1086 ms 24204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1090 ms 24384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1093 ms 35680 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1083 ms 35668 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1086 ms 38688 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1078 ms 38724 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1080 ms 42032 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1088 ms 41836 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1080 ms 48092 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1087 ms 48088 KB Time limit exceeded
2 Halted 0 ms 0 KB -