# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1111010 |
2024-11-11T09:53:05 Z |
vjudge1 |
Mobile (BOI12_mobile) |
C++17 |
|
916 ms |
24176 KB |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
using std::mt19937_64;
using std::random_device;
using std::uniform_int_distribution;
#include <numeric>
#define ff first
#define ss second
#define int long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define pqb priority_queue<int>
#define pqs priority_queue<int,vi,greater<int> >
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x
#define mk(arr,n,type) type *arr=new type[n];
#define w(x) int x; cin>>x; while(x--)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void c_p_c()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("milkvisits.in", "r", stdin);
freopen("milkvisits.out", "w", stdout);
#endif
}
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int exp(int x, int n, int m) {
if(x == 0 and n == 0) return 1;
x %= m;
int res = 1;
while (n > 0) {
if (n % 2 == 1) { res = res * x % m; }
x = x * x % m;
n /= 2;
}
return res;
}
bool check(double mid,vector<pair<int,int>> &v,int k,int n){
double dist = mid*mid;
for(int i = 0 ; i < n-1; i++){
double disty = v[i].ss*v[i].ss;
if(dist-disty >= 0){
double x = v[i].ff + sqrtl(dist-disty);
double x2 = v[i].ff - sqrtl(dist-disty);
if(x <= v[i+1].ff and x <= k and x >= 0){
double dista = (x-v[i+1].ff)*(x-v[i+1].ff)+(v[i+1].ss*v[i+1].ss);
if(dista >= dist) {
// cout<<x<<" "<<dista<<endl;
return true;
}
}
if(i > 0){
if(x2 >= 0 and x2 >= v[i-1].ff){
double dista = (x2-v[i-1].ff)*(x2-v[i-1].ff)+(v[i-1].ss*v[i-1].ss);
if(dista >= dist) {
// cout<<x2<<" "<<dista<<endl;
return true;
}
}
}
}
}
if(k >= v[n-1].ff){
double dista = (k-v[n-1].ff)*(k-v[n-1].ff)+(v[n-1].ss*v[n-1].ss);
if(dista >= dist) {
// cout<<k<<" "<<dista<<endl;
return true;
}
}
return false;
}
signed main()
{
int t=1;
// c_p_c();
// cin >> t;
while(t--){
int n,k;
cin >> n >> k;
vector<pair<int,int>> v;
for(int i = 0 ; i < n; i++){
int x,y;
cin >> x >> y;
if(v.empty()){
v.pb({x,y});
continue;
}
if(v.back().ff == x){
v.back().ss = min(v.back().ss,abs(y));
}
else{
v.pb({x,y});
}
}
n = v.size();
// cout<<n<<endl;
double l = 0, r = 1500000000;
double ans;
while(l <= r){
double mid = l + (r-l)/2;
if(check(mid,v,k,n)){
ans = mid;
l = mid+0.0001;
}
else{
r = mid-0.0001;
}
}
cout<<fixed<<setprecision(3);
cout<<ans<<endl;
}
return 0;
}
Compilation message
mobile.cpp: In function 'void c_p_c()':
mobile.cpp:36:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
36 | freopen("milkvisits.in", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:37:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
37 | freopen("milkvisits.out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
592 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
592 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
48 ms |
4248 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
25 ms |
592 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
80 ms |
4036 KB |
Output is correct |
2 |
Incorrect |
48 ms |
1992 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
57 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
103 ms |
4540 KB |
Output is correct |
2 |
Incorrect |
57 ms |
2704 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
455 ms |
12492 KB |
Output is correct |
2 |
Incorrect |
225 ms |
4700 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
220 ms |
4824 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
525 ms |
22704 KB |
Output is correct |
2 |
Incorrect |
245 ms |
8776 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
259 ms |
9032 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
610 ms |
21428 KB |
Output is correct |
2 |
Incorrect |
294 ms |
8712 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
322 ms |
7636 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
721 ms |
21044 KB |
Output is correct |
2 |
Incorrect |
353 ms |
7496 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
401 ms |
9544 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
916 ms |
24176 KB |
Output is correct |
2 |
Incorrect |
418 ms |
10212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
468 ms |
14320 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |