# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
916315 |
2024-01-25T16:17:37 Z |
asdasdqwer |
Mobile (BOI12_mobile) |
C++14 |
|
1000 ms |
81492 KB |
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define pii array<int,2>
#define double long double
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n,t;cin>>n>>t;
vector<pii> v(n);
for (auto &x:v)cin>>x[0]>>x[1];
vector<pii> tt;
for (auto &x:v) {
if (!tt.size()) {
tt.push_back(x);
}
else if (tt.back()[0] == x[0] && abs(tt.back()[1]) > abs(x[1])) {
tt.pop_back();
}
tt.push_back(x);
}
v=tt;
n=v.size();
double l = 1;
double r = 1e15;
vector<bool> rem(n, false);
while (abs(l-r) > 0.0001) {
double m = (l+r)/2.0;
int i=0;
vector<array<double,2>> start;
bool all=false;
for (auto &x:v) {
if ((double)abs(x[1]) >= m) {
rem[i]=true;
}
if (rem[i]) {
i++;
continue;
}
else {
double aa=(double)abs(x[1]);
double dis=sqrt(m*m-aa*aa);
array<double,2> pos1 = {x[0]-dis,x[0]+dis};
if ((pos1[0] < 0.0 && pos1[1] < 0.0) || (pos1[0] > (double)t && pos1[1] > (double)t)) {
rem[i]=true;
}
else {
pos1[0]=max(pos1[0], (double)0.0);
pos1[1]=min(pos1[1], (double)t);
if (pos1[0] == 0.0 && pos1[1] == t) {
all=true;
break;
}
start.push_back(pos1);
}
}
i++;
}
if (all) {
r=m;
continue;
}
start.push_back({0.0, 0.0});
start.push_back({(double)t,(double)t});
sort(start.begin(),start.end());
// cout<<m<<" "<<l<<" "<<r<<"\n";
// for (auto &x:start) {
// cout<<x[0]<<" "<<x[1]<<"\n";
// }
// cout<<"\n";
// for (auto &x:v) {
// cout<<x[0]<<" "<<x[1]<<"\n";
// }
// cout<<"\n\n";
array<double,2> pos={0.0, 0.0};
bool possible=true;
for (auto &x:start) {
if (x[0] <= pos[1]) {
pos[1]=max(pos[1], x[1]);
}
else {
possible=false;
break;
}
}
if (possible) {
r=m;
int cnt=0;
int pt=0;
for (int i=0;i<n;i++) {
if (rem[i]) {
cnt++;
}
else if (cnt != 0) {
swap(v[i], v[pt]);
}
if (!rem[i]) {
pt++;
}
}
n -= cnt;
while (v.size() != n){
v.pop_back();
rem.pop_back();
}
for (int i=0;i<n;i++) {
rem[i]=false;
}
}
else {
l=m;
for (i=0;i<n;i++) {
rem[i]=false;
}
}
}
cout<<setprecision(15);
cout<<r<<"\n";
}
Compilation message
mobile.cpp: In function 'int main()':
mobile.cpp:131:29: warning: comparison of integer expressions of different signedness: 'std::vector<std::array<long int, 2> >::size_type' {aka 'long unsigned int'} and 'int64_t' {aka 'long int'} [-Wsign-compare]
131 | while (v.size() != n){
| ~~~~~~~~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
6 ms |
808 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
3 ms |
672 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
604 KB |
Output is correct |
2 |
Correct |
7 ms |
1052 KB |
Output is correct |
3 |
Correct |
7 ms |
876 KB |
Output is correct |
4 |
Correct |
2 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
604 KB |
Output is correct |
2 |
Correct |
7 ms |
1052 KB |
Output is correct |
3 |
Correct |
8 ms |
860 KB |
Output is correct |
4 |
Correct |
2 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
860 KB |
Output is correct |
2 |
Correct |
8 ms |
1052 KB |
Output is correct |
3 |
Correct |
7 ms |
880 KB |
Output is correct |
4 |
Correct |
2 ms |
604 KB |
Output is correct |
5 |
Correct |
2 ms |
600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
70 ms |
6464 KB |
Output is correct |
2 |
Correct |
236 ms |
10564 KB |
Output is correct |
3 |
Correct |
165 ms |
5380 KB |
Output is correct |
4 |
Correct |
24 ms |
4564 KB |
Output is correct |
5 |
Correct |
8 ms |
2008 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
3028 KB |
Output is correct |
2 |
Correct |
20 ms |
3700 KB |
Output is correct |
3 |
Correct |
19 ms |
4564 KB |
Output is correct |
4 |
Correct |
21 ms |
4564 KB |
Output is correct |
5 |
Correct |
23 ms |
5020 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
430 ms |
10356 KB |
Output is correct |
2 |
Correct |
280 ms |
9752 KB |
Output is correct |
3 |
Correct |
141 ms |
7424 KB |
Output is correct |
4 |
Correct |
27 ms |
5584 KB |
Output is correct |
5 |
Correct |
18 ms |
4052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
222 ms |
11924 KB |
Output is correct |
2 |
Correct |
366 ms |
10936 KB |
Output is correct |
3 |
Correct |
265 ms |
10764 KB |
Output is correct |
4 |
Correct |
27 ms |
5588 KB |
Output is correct |
5 |
Correct |
24 ms |
5076 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
206 ms |
7428 KB |
Output is correct |
2 |
Correct |
333 ms |
11448 KB |
Output is correct |
3 |
Correct |
322 ms |
10808 KB |
Output is correct |
4 |
Correct |
29 ms |
5588 KB |
Output is correct |
5 |
Correct |
23 ms |
5328 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1066 ms |
48364 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1029 ms |
48500 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1010 ms |
69804 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1051 ms |
71844 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1022 ms |
73080 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1038 ms |
74860 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1044 ms |
77680 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1038 ms |
78528 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1030 ms |
81492 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1010 ms |
81432 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |