Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#include <cassert>
- //
- ///** Begin fast allocation */
- //const int MAX_MEM = 2e8 + 6e7;
- //int mpos = 0;
- //char mem[MAX_MEM];
- //inline void * operator new (size_t n) {
- // assert((mpos += n) <= MAX_MEM);
- // return (void *)(mem + mpos - n);
- //}
- //void operator delete (void *) noexcePoint { } // must have!
- //void operator delete (void *, size_t) noexcePoint { } // must have!
- ///** End fast allocation */
- #pragma GCC oPointimize("Ofast")
- //#pragma GCC oPointimize ("unroll-loops")
- //#pragma GCC oPointimize ("fast-math")
- #pragma GCC target("avx2")
- //#include <bits/stdc++.h>
- #include <iostream>
- #include <algorithm>
- #include <string>
- #include <cmath>
- #include <vector>
- #include <map>
- #include <set>
- #include <list>
- #include <ctime>
- #include <stack>
- #include <queue>
- #include <iomanip>
- #include <cstdlib>
- #include <unordered_map>
- #include <unordered_set>
- #include <cstddef>
- #include <deque>
- #include <cstdio>
- #include <fstream>
- #include <random>
- #include <climits>
- #include <cassert>
- #include <chrono>
- #include <complex>
- using namespace std;
- #define forn(i, j, k) for(int i = (int)(j); i < (int)(k); i++)
- #define forn1(i, j, k) for(int i = (int)(j); i <= (int)(k); i++)
- #define pb push_back
- #define mp make_pair
- #define f first
- #define s second
- #define all(x) begin(x), end(x)
- #define sz(a) ((int)((a).size()))
- #define endl '\n'
- const int INF = 1e9 + 1;
- const long long MOD = 1'000'000'007;
- typedef long long ll;
- typedef unsigned long long ull;
- typedef long double ld;
- std::mt19937 rnd(chrono::system_clock::now().time_since_epoch().count());
- struct hash_function {
- size_t operator() (const pair<int, int>& p) const {
- return p.first ^ p.second;
- }
- };
- const int ITERS = 1'000'000;
- const long double EPS = 1e-6;
- inline pair<double, double> intersect(double x, double y, int r, double x0) {
- if (x0 <= x - r || x + r <= x0) {
- return {1e18, 1e18};
- }
- // (x - x0)^2 + (y - y0)^2 = r^2
- return {y - sqrt((r * r) - (x - x0) * (x - x0)), y + sqrt((r * r) - (x - x0) * (x - x0))};
- }
- vector<tuple<int, int, int>> arr = {{0 , 0, 100}, {-40, 30, 30}, {40, 30, 30}, {0, -20, 60}};
- pair<double, double> cur, cur1;
- inline void add_points(vector<pair<double, int>>& line, int x, int y, double l, double r) {
- for (auto [a, b, c] : arr) {
- cur = intersect(x + a, y + b, c, l);
- cur1 = intersect(x + a, y + b, c, r);
- if (1e9 > cur.first) {
- line.emplace_back((cur.first + cur1.first) / 2, 1);
- line.emplace_back((cur.second + cur1.second) / 2, 0);
- }
- }
- }
- void solve() {
- int x1, y1, x2, y2;
- cin >> x1 >> y1 >> x2 >> y2;
- if (min(x1, x2) + 100 <= max(x1, x2) - 100) {
- cout << "40212.3859659494\n";
- return;
- }
- int minx = min(x1, x2) - 100;
- int maxx = max(x1, x2) + 100;
- // int maxx = -80;
- double step = double(maxx - minx) / ITERS;
- double ans = 0;
- for (int _ = 0; _ < ITERS; ++_) {
- double l = double(minx) + step * _;
- double r = double(minx) + step * (_ + 1);
- vector<pair<double, int>> line; // y_coordinate 1 if add, 0 if minus
- add_points(line, x1, y1, l, r);
- add_points(line, x2, y2, l, r);
- sort(line.begin(), line.end());
- int cnt = 0;
- double pred = 0;
- for (auto & i : line) {
- if (cnt > 0) {
- ans += (i.first - pred);
- }
- if (i.second == 0) {
- --cnt;
- } else {
- ++cnt;
- }
- pred = i.first;
- }
- }
- cout << ans * step << endl;
- }
- int32_t main() {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- cout.tie(NULL);
- cout.precision(30);
- int testCases = 1;
- #ifdef LOCAL
- freopen("input.txt", "r", stdin);
- //freopen("output.txt", "w", stdout);
- cin >> testCases;
- #else
- //freopen("inputik.txt", "r", stdin);
- //freopen("outputik.txt", "w", stdout);
- testCases = 1;
- #endif
- while (testCases--) {
- solve();
- #ifdef LOCAL
- cout << "__________________________" << endl;
- #endif
- }
- #ifdef LOCAL
- cerr << endl << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl;
- #endif
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement