답안 #671159

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
671159 2022-12-12T08:58:27 Z vjudge1 Mobile (BOI12_mobile) C++14
8 / 100
1000 ms 24920 KB
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
using vi = vector<int>;
using ll = long long;
using pii = pair<ll, int>;

const int maxn = 1e6 + 7;
double x[maxn], y[maxn];
double L;
int n;

bool check(double r) {
	vector<pair<double, double>> seg;
	rep(i, 0, n) {
		if (abs(y[i]) < r) {
			double dy = abs(y[i]);
			double tmp = r * r - dy * dy;
			double dx = sqrt(tmp);
			double x1 = x[i] - dx, x2 = x[i] + dx;
			if (x1 < 0.0 && x2 < 0.0) continue;
			if (x1 > L && x2 > L) continue;
			if (seg.empty()) {
				seg.push_back({x1, x2});
			} else {
				while (!seg.empty()) {
					auto p = seg.back();
					if (p.f >= x1 && p.s <= x2) {
						seg.pop_back();
					} else if (p.f <= x1 && p.s <= x2 && p.s >= x1) {
						seg.pop_back();
						x1 = p.f;
					} else {
						break;
					}
				}
				seg.push_back({x1, x2});
			}
		} 
	}
	if (seg.size() >= 1) {
		if (seg[0].f <= 0 && seg[0].s >= L) return true;
	}
	return false;
}

int main() {
	//ios::sync_with_stdio(false);
	scanf("%d %lf", &n, &L);
	rep(i, 0, n) {
		scanf("%lf %lf", &x[i], &y[i]);
	}
	double l = 0.0, r = 1e9;
	rep(it, 0, 75) {
		double mid = l + (r - l) / 2.0;
		if (check(mid)) {
			r = mid;
		} else {
			l = mid;
		}
	}
	printf("%.6lf\n", l);
}	

Compilation message

mobile.cpp: In function 'int main()':
mobile.cpp:67:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   67 |  scanf("%d %lf", &n, &L);
      |  ~~~~~^~~~~~~~~~~~~~~~~~
mobile.cpp:69:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   69 |   scanf("%lf %lf", &x[i], &y[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 4 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 340 KB Output is correct
2 Correct 7 ms 340 KB Output is correct
3 Correct 7 ms 324 KB Output is correct
4 Incorrect 4 ms 448 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 7 ms 340 KB Output is correct
3 Correct 6 ms 340 KB Output is correct
4 Correct 4 ms 596 KB Output is correct
5 Incorrect 5 ms 340 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 73 ms 1440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 55 ms 1520 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 118 ms 1668 KB Output is correct
2 Correct 115 ms 1716 KB Output is correct
3 Correct 98 ms 1860 KB Output is correct
4 Correct 48 ms 1980 KB Output is correct
5 Incorrect 66 ms 2532 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 148 ms 1860 KB Output is correct
2 Correct 137 ms 1976 KB Output is correct
3 Correct 115 ms 1984 KB Output is correct
4 Incorrect 50 ms 1976 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 90 ms 1876 KB Output is correct
2 Correct 141 ms 3272 KB Output is correct
3 Correct 118 ms 3000 KB Output is correct
4 Incorrect 51 ms 3804 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 662 ms 8120 KB Output is correct
2 Correct 689 ms 15820 KB Output is correct
3 Correct 699 ms 15276 KB Output is correct
4 Incorrect 248 ms 17612 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 680 ms 8124 KB Output is correct
2 Incorrect 543 ms 14668 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 795 ms 9688 KB Output is correct
2 Correct 806 ms 18968 KB Output is correct
3 Correct 814 ms 18496 KB Output is correct
4 Incorrect 284 ms 21564 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 806 ms 9688 KB Output is correct
2 Incorrect 642 ms 17596 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 920 ms 11376 KB Output is correct
2 Correct 956 ms 22156 KB Output is correct
3 Correct 948 ms 21484 KB Output is correct
4 Incorrect 349 ms 24920 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 939 ms 11256 KB Output is correct
2 Incorrect 713 ms 20428 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1054 ms 12936 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1069 ms 12832 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1097 ms 15808 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1098 ms 15952 KB Time limit exceeded
2 Halted 0 ms 0 KB -