Submission #671151

# Submission time Handle Problem Language Result Execution time Memory
671151 2022-12-12T08:24:47 Z vjudge1 Mobile (BOI12_mobile) C++17
0 / 100
1000 ms 47480 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++;
		} 
	}
	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:63:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |  scanf("%d %lf", &n, &L);
      |  ~~~~~^~~~~~~~~~~~~~~~~~
mobile.cpp:65:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   65 |   scanf("%lf %lf", &x[i], &y[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 396 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 436 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 768 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 1020 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 1060 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 852 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 43 ms 7740 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 46 ms 9232 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 641 ms 4724 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 51 ms 4048 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 35 ms 3648 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1086 ms 24072 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 159 ms 16816 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1074 ms 28800 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 192 ms 20016 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1081 ms 33580 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 230 ms 23304 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1074 ms 38172 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 251 ms 26408 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1102 ms 47480 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 316 ms 32660 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -