Submission #671153

# Submission time Handle Problem Language Result Execution time Memory
671153 2022-12-12T08:27:06 Z vjudge1 Mobile (BOI12_mobile) C++11
0 / 100
1000 ms 47524 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 = 2e6 + 7;
double x[maxn], y[maxn];
pair<double, int> pt[maxn];
double L;
int n;

bool check(double r) {
	int m = 0;
	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;
			pt[m].f = max(0.0, x1); pt[m].s = -1; m++;
			pt[m].f = min(L, x2); pt[m].s = 1; m++;
		} 
	}
	if (m == 0) return false;
	sort(pt, pt + m);
	stack<double> st;
	double len = 0.0;
	rep(i, 0, m) {
		if (pt[i].s == -1) {
			st.push(pt[i].f);
		} else {
			double dis = pt[i].f - st.top();
			st.pop();
			if (st.empty()) {
				len += dis;
			}
		}
	}
	return len >= L;
}

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 = 1e4;
	rep(it, 0, 70) {
		double mid = l + (r - l) / 2;
		if (check(mid)) {
			r = mid;
		} else {
			l = mid;
		}
	}
	printf("%.6lf\n", l);
}	

Compilation message

mobile.cpp: In function 'int main()':
mobile.cpp:64:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   64 |  scanf("%d %lf", &n, &L);
      |  ~~~~~^~~~~~~~~~~~~~~~~~
mobile.cpp:66:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   66 |   scanf("%lf %lf", &x[i], &y[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 724 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 980 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 976 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 852 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 30 ms 7540 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 41 ms 9100 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 555 ms 4680 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 33 ms 3916 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 35 ms 3588 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1093 ms 23864 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 158 ms 16692 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1093 ms 28764 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 190 ms 19808 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1095 ms 33424 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 214 ms 22968 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1097 ms 37972 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 249 ms 26156 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1093 ms 47524 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 312 ms 32516 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -