Submission #671160

# Submission time Handle Problem Language Result Execution time Memory
671160 2022-12-12T09:00:36 Z vjudge1 Mobile (BOI12_mobile) C++14
8 / 100
943 ms 31436 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;
	while (r - l > 0.0001) {
		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]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 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 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 340 KB Output is correct
2 Correct 3 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
# 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 Correct 4 ms 340 KB Output is correct
2 Correct 5 ms 340 KB Output is correct
3 Correct 5 ms 340 KB Output is correct
4 Incorrect 5 ms 340 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 340 KB Output is correct
2 Correct 5 ms 340 KB Output is correct
3 Correct 6 ms 340 KB Output is correct
4 Correct 4 ms 468 KB Output is correct
5 Incorrect 5 ms 320 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 56 ms 1364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 54 ms 1428 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 85 ms 1932 KB Output is correct
2 Correct 80 ms 1848 KB Output is correct
3 Correct 70 ms 1876 KB Output is correct
4 Correct 46 ms 2112 KB Output is correct
5 Incorrect 65 ms 1948 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 104 ms 1996 KB Output is correct
2 Correct 96 ms 2084 KB Output is correct
3 Correct 85 ms 2124 KB Output is correct
4 Incorrect 47 ms 2116 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 69 ms 2084 KB Output is correct
2 Correct 100 ms 2116 KB Output is correct
3 Correct 105 ms 2120 KB Output is correct
4 Incorrect 48 ms 2016 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 449 ms 8372 KB Output is correct
2 Correct 482 ms 8268 KB Output is correct
3 Correct 495 ms 8376 KB Output is correct
4 Incorrect 254 ms 8328 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 496 ms 8388 KB Output is correct
2 Incorrect 396 ms 8380 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 592 ms 9948 KB Output is correct
2 Correct 563 ms 10116 KB Output is correct
3 Correct 566 ms 9956 KB Output is correct
4 Incorrect 266 ms 9948 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 588 ms 10084 KB Output is correct
2 Incorrect 474 ms 10056 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 639 ms 11504 KB Output is correct
2 Correct 687 ms 11516 KB Output is correct
3 Correct 655 ms 11516 KB Output is correct
4 Incorrect 332 ms 11508 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 655 ms 11844 KB Output is correct
2 Incorrect 511 ms 11636 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 718 ms 13068 KB Output is correct
2 Correct 764 ms 25224 KB Output is correct
3 Correct 739 ms 24436 KB Output is correct
4 Correct 377 ms 28384 KB Output is correct
5 Incorrect 519 ms 23956 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 744 ms 13212 KB Output is correct
2 Incorrect 560 ms 23420 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 914 ms 16184 KB Output is correct
2 Correct 929 ms 31436 KB Output is correct
3 Correct 930 ms 30484 KB Output is correct
4 Incorrect 478 ms 17288 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 943 ms 16632 KB Output is correct
2 Incorrect 695 ms 29056 KB Output isn't correct
3 Halted 0 ms 0 KB -