Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <algorithm>
- #include <utility>
- #include <cmath>
- using namespace std;
- pair <double, int> l[1000000];
- struct Point
- {
- double x, y;
- Point() {}
- Point(double a, double b) {x = a, y = b;}
- };
- double Less(Point a, Point b)
- {
- return (a.first < a.first);
- }
- int main()
- {
- int n, i, k = 0;
- double s = 0, r1, r2, lf = 0;
- double rmin = 1000001, rmax = 0;
- scanf("%d", &n);
- for ( i = 0; i < n; i++)
- {
- scanf("%lf %lf %lf %lf", &r1, &r2, &l[2 * i].first, &l[2 * i + 1].first);
- rmin = min(rmin, r1);
- rmax = max(rmax, r2);
- l[2 * i].second = 1;
- l[2 * i + 1].second = 2;
- if ( l[2 * i].first > l[2 * i + 1].first )
- {
- k++;
- lf = max(lf, l[2 * i].first);
- }
- }
- sort(l, l + 2 * n, Less);
- for ( i = 1; i < 2 * n; i++)
- {
- if ( k == n)
- {
- s += ((l[i].first - lf) * rmax * rmax - (l[i].first - lf) * rmin * rmin) / 2;
- lf = l[i].first;
- }
- if ( l[i].second == 1)
- {
- k++;
- lf = l[i].first;
- }
- }
- printf("%10.lf", s);
- return 0;
- }
Add Comment
Please, Sign In to add comment