Submission #285995

#TimeUsernameProblemLanguageResultExecution timeMemory
285995__SIGSEGV__Mobile (BOI12_mobile)C++17
0 / 100
1100 ms41188 KiB
#include <iostream> #include <cstdio> #include <cstdlib> #include <algorithm> #include <cmath> #include <vector> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <queue> #include <ctime> #include <cassert> #include <complex> #include <string> #include <cstring> #include <chrono> #include <random> #include <bitset> #include <numeric> using namespace std; #define forr(x, n) for (int x = n; x >= 0; x--) #define forn(x, n) for (int x = 0; x < n; x++) #define fore(x, a, b, c) for (int x = a; x <= b; x += c) #define for1(x, n) for (int x = 1; x < n; x++) #define all(container) (container).begin(), (container).end() #define rall(container) (container).rbegin(), (container).rend() #define sz(container) (int) container.size() #define pb push_back #define eb emplace_back #define mp make_pair #define mt make_tuple #define fi first #define se second #ifdef LOCAL_DEFINE #include "../DEBUG.hpp" #else #define debug(...) 0 #endif using i64 = long long; using pi64 = pair<i64, i64>; using vi = vector<int>; using vi64 = vector<i64>; using pii = pair<int, int>; using vpii = vector<pair<int, int>>; using vs = vector<string>; using vb = vector<bool>; using vvb = vector<vector<bool>>; using vvi = vector<vector<int>>; using vvi64 = vector<vector<i64>>; using vpi64 = vector<pi64>; template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; } template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; } const double eps = 1e-9; bool eq(double a, double b) { return abs(a - b) <= eps; } int main(void) { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.precision(10); cout << fixed; #ifdef LOCAL_DEFINE freopen("input.txt", "r", stdin); #endif int n; double l; cin >> n >> l; vector<pair<double, double>> points(n); forn(i, n) cin >> points[i].fi >> points[i].se; vector<pair<double, double>> poi; forn(i, n) { poi.eb(points[i]); ++i; while (i < n && eq(points[i].fi, poi.back().fi)) ++i; --i; } auto f = [&](double x, const pair<double, double> &p1, const pair<double, double> &p2) { double d1 = sqrt((x - p1.fi) * (x - p1.fi) + p1.se * p1.se); double d2 = sqrt((p2.fi - x) * (p2.fi - x) + p2.se * p2.se); double ret = min(d1, d2); return ret; }; double ans = 0.0; forn(i, n - 1) { double left = max(0.0, min(poi[i].fi, l)); double right = max(0.0, min(poi[i + 1].fi, l)); while (right - left > eps) { double p1 = left + (right - left) / 3.0, p2 = right - (right - left) / 3.0; double f1 = f(p1, poi[i], poi[i + 1]), f2 = f(p2, poi[i], poi[i + 1]); if (f1 < f2) left = p1; else right = p2; } uax(ans, f(left, poi[i], poi[i + 1])); } cout << ans << '\n'; #ifdef LOCAL_DEFINE cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << '\n'; #endif return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...