Submission #526152

# Submission time Handle Problem Language Result Execution time Memory
526152 2022-02-13T20:32:50 Z Bungmint Mobile (BOI12_mobile) C++17
100 / 100
362 ms 27476 KB
//Copyright © 2021 Youngmin Park. All rights reserved.
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using vpi = vector<pii>;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vpl = vector<pll>;
using ld = long double;

#define all(v) (v).begin(), (v).end()
#define ar array
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i, 0, a)
#define REP(a) F0R(_, a)

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7; //998244353;
const ld PI = acos((ld)-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>
using pqg = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
bool ckmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template <typename T>
bool ckmax(T &a, const T &b) { return b > a ? a = b, 1 : 0; }

template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p)
{
    return os << '(' << p.first << ", " << p.second << ')';
}
template <typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type>
ostream &operator<<(ostream &os, const T_container &v)
{
    os << '{';
    string sep;
    for (const T &x : v)
        os << sep << x, sep = ", ";
    return os << '}';
}
void dbg_out()
{
    cerr << endl;
}
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T)
{
    cerr << ' ' << H;
    dbg_out(T...);
}
#ifdef LOCAL
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...) 42
#endif

struct chash
{
    static uint64_t splitmix64(uint64_t x)
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
    size_t operator()(pair<uint64_t,uint64_t> x) const {
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);
	}
};

void setIO(string s)
{
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}

const double EPS = 1e-4;
const int N = 1e6;
pii a[N];

void solve()
{
	double n, L;
	cin >> n >> L;
	F0R(i, n) cin >> a[i].fi >> a[i].se;
	double l = 0, r = 2e9, ans = 0;
	while(r-l>EPS){
		double mid = (r+l)/2;
		double cur = 0;
		F0R(i, n){
			auto&[x,y] = a[i];
			if (1LL*y*y>mid*mid) continue;
			double val = sqrt(mid*mid-1LL*y*y);
			double lll = x-val, rrr=x+val;
			if (lll<=cur) cur = max(cur, rrr);
		}
		if (cur+EPS<L) l = mid;
		else r = mid, ans = mid;
	}
	cout << fixed << setprecision(20) << ans;
}

int main()
{
    cin.tie(0)->sync_with_stdio(0);
    cin.exceptions(cin.failbit);
    int testcase=1;
    // cin >> testcase;
    while (testcase--)
    {
        solve();
    }
}

Compilation message

mobile.cpp: In function 'void setIO(std::string)':
mobile.cpp:96:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   96 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:97:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   97 |     freopen((s + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 368 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 2 ms 400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 3 ms 400 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 1608 KB Output is correct
2 Correct 22 ms 1988 KB Output is correct
3 Correct 18 ms 1356 KB Output is correct
4 Correct 19 ms 2012 KB Output is correct
5 Correct 11 ms 1028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 1604 KB Output is correct
2 Correct 18 ms 1576 KB Output is correct
3 Correct 20 ms 1884 KB Output is correct
4 Correct 22 ms 2132 KB Output is correct
5 Correct 23 ms 2364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 1592 KB Output is correct
2 Correct 24 ms 1992 KB Output is correct
3 Correct 22 ms 1872 KB Output is correct
4 Correct 29 ms 2964 KB Output is correct
5 Correct 22 ms 1988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 2168 KB Output is correct
2 Correct 29 ms 2212 KB Output is correct
3 Correct 25 ms 2112 KB Output is correct
4 Correct 29 ms 2980 KB Output is correct
5 Correct 25 ms 2256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 2244 KB Output is correct
2 Correct 29 ms 2500 KB Output is correct
3 Correct 25 ms 2112 KB Output is correct
4 Correct 28 ms 3012 KB Output is correct
5 Correct 26 ms 2260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 121 ms 5316 KB Output is correct
2 Correct 154 ms 11844 KB Output is correct
3 Correct 148 ms 11560 KB Output is correct
4 Correct 136 ms 13764 KB Output is correct
5 Correct 132 ms 11108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 147 ms 5316 KB Output is correct
2 Correct 199 ms 10960 KB Output is correct
3 Correct 122 ms 9924 KB Output is correct
4 Correct 133 ms 13508 KB Output is correct
5 Correct 124 ms 11400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 149 ms 6060 KB Output is correct
2 Correct 173 ms 14276 KB Output is correct
3 Correct 175 ms 13660 KB Output is correct
4 Correct 164 ms 16908 KB Output is correct
5 Correct 150 ms 12972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 184 ms 6272 KB Output is correct
2 Correct 235 ms 12864 KB Output is correct
3 Correct 147 ms 11852 KB Output is correct
4 Correct 162 ms 16740 KB Output is correct
5 Correct 150 ms 13844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 167 ms 6956 KB Output is correct
2 Correct 205 ms 16660 KB Output is correct
3 Correct 201 ms 16012 KB Output is correct
4 Correct 188 ms 19280 KB Output is correct
5 Correct 169 ms 14836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 204 ms 6960 KB Output is correct
2 Correct 275 ms 15012 KB Output is correct
3 Correct 179 ms 14144 KB Output is correct
4 Correct 191 ms 19076 KB Output is correct
5 Correct 179 ms 15876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 194 ms 7784 KB Output is correct
2 Correct 230 ms 18872 KB Output is correct
3 Correct 231 ms 18244 KB Output is correct
4 Correct 222 ms 22288 KB Output is correct
5 Correct 201 ms 17888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 244 ms 7616 KB Output is correct
2 Correct 302 ms 17088 KB Output is correct
3 Correct 205 ms 16200 KB Output is correct
4 Correct 224 ms 22064 KB Output is correct
5 Correct 202 ms 18192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 243 ms 9284 KB Output is correct
2 Correct 291 ms 23856 KB Output is correct
3 Correct 283 ms 22788 KB Output is correct
4 Correct 268 ms 27476 KB Output is correct
5 Correct 254 ms 21600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 288 ms 8172 KB Output is correct
2 Correct 362 ms 21404 KB Output is correct
3 Correct 266 ms 20524 KB Output is correct
4 Correct 272 ms 27460 KB Output is correct
5 Correct 257 ms 22792 KB Output is correct