# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
445958 |
2021-07-20T09:15:47 Z |
Qw3rTy |
Mobile (BOI12_mobile) |
C++11 |
|
1000 ms |
31560 KB |
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define int long long
#define db double
#define delta 1e-6
#define INF 1e9+5
#define pi pair<int,int>
#define pb pair<db,db>
#define fi first
#define se second
using namespace std;
const int maxN = 1e6+5;
int N,L;
pi tower[maxN];
pb inter[maxN]; //intersections
bool cmp(pb a, pb b){
if(abs(a.fi - b.fi) < delta)return a.se < b.se;
return a.fi < b.fi;
}
bool works(db r){
for(int i = 1; i <= N; ++i)inter[i].fi = inter[i].se = -INF;
for(int i = 1; i <= N; ++i) {
//Can't reach any point on the highway
if (r * r - tower[i].se * tower[i].se < 0)continue;
inter[i].fi = tower[i].fi - sqrt(r*r - tower[i].se*tower[i].se);
inter[i].se = tower[i].fi + sqrt(r*r + tower[i].se*tower[i].se);
inter[i].fi = (inter[i].fi < 0)?0:inter[i].fi;
inter[i].se = (inter[i].se > L)?L:inter[i].se;
}
sort(inter+1,inter+N+1,cmp);
db a = 0; db b = 0;
for(int i = 1; i <= N; ++i){
//Invalid intersections
if(inter[i].fi > inter[i].se)continue;
//Merge intervals
if(inter[i].fi <= b)b = (inter[i].se > b)?inter[i].se:b;
else return false;
}
if(abs(a-0) < delta && abs(b-L) < delta)return true;
return false;
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
//freopen("../test.in","r",stdin);
cin >> N >> L;
for(int i = 1; i <= N; ++i)cin >> tower[i].fi >> tower[i].se;
db low = 1; db high = 2e9;
while(abs(high-low) > delta){
db mid = (low+high)/2;
if(works(mid))high = mid;
else low = mid + delta;
}
cout << setprecision(6) << low << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
488 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
488 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
14 ms |
460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
180 ms |
2656 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
171 ms |
2816 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
218 ms |
2984 KB |
Output is correct |
2 |
Incorrect |
292 ms |
2892 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
319 ms |
3360 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
265 ms |
3416 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1086 ms |
15936 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1081 ms |
15972 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1089 ms |
19012 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1073 ms |
19008 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1090 ms |
22276 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1094 ms |
22212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1091 ms |
25284 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1086 ms |
25540 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1085 ms |
31560 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1092 ms |
31524 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |