Cod sursa(job #3217440)

Utilizator SochuDarabaneanu Liviu Eugen Sochu Data 22 martie 2024 22:19:54
Problema Reuniune Scor 20
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 2.29 kb
#include <bits/stdc++.h>
//#pragma GCC optimize ("03")
#define FastIO ios_base::sync_with_stdio(false) , cin.tie(0) , cout.tie(0)
#define FILES freopen("reuniune.in" , "r" , stdin) , freopen("reuniune.out" , "w" , stdout)
#define ll long long
#define ull unsigned long long
#define ld long double
#define eb emplace_back
#define pb push_back
#define qwerty1 first
#define qwerty2 second
#define qwerty3 -> first
#define qwerty4 -> second
#define umap unordered_map
#define uset unordered_set
#define pii pair < ll , ll >
#define pq priority_queue
#define dbg(x) cerr << #x << ": " << x << '\n'

namespace FastRead
{
    char __buff[5000];ll __lg = 0 , __p = 0;
    char nc()
    {
        if(__lg == __p){__lg = fread(__buff , 1 , 5000 , stdin);__p = 0;if(!__lg) return EOF;}
        return __buff[__p++];
    }
    template<class T>void read(T&__x)
    {
        T __sgn = 1; char __c;while(!isdigit(__c = nc()))if(__c == '-')__sgn = -1;
        __x = __c - '0';while(isdigit(__c = nc()))__x = __x * 10 + __c - '0';__x *= __sgn;
    }
}

using namespace FastRead;
using namespace std;

const ll N = 1e5 + 10;
const ll M = 1e9 + 7;
const ld PI = acos(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

struct rectangle
{
    int x1 , y1 , x2 , y2;
}rec[N];

rectangle Union(rectangle a , rectangle b)
{
    rectangle u;
    u.x1 = max(a.x1 , b.x1);
    u.y1 = max(a.y1 , b.y1);

    u.x2 = min(a.x2 , b.x2);
    u.y2 = min(a.y2 , b.y2);

    return u;
}

ll perimeter(rectangle a)
{
    return (a.x2 - a.x1) * 2 + (a.y2 - a.y1) * 2;
}

ll area(rectangle a)
{
    return (a.x2 - a.x1) * (a.y2 - a.y1);
}

signed main()
{
	#ifndef ONLINE_JUDGE
		FastIO , FILES;
	#endif

    for(int i = 1 ; i <= 3 ; i++)
    {
        cin >> rec[i].x1 >> rec[i].y1 >> rec[i].x2 >> rec[i].y2;
    }

    rectangle u1 = Union(rec[1] , rec[2]);
    rectangle u2 = Union(rec[1] , rec[3]);
    rectangle u3 = Union(rec[2] , rec[3]);
    rectangle u4 = Union(rec[1] , u3);

    ll A = area(rec[1]) + area(rec[2]) + area(rec[3]) - area(u1) - area(u2) - area(u3) + area(u4);
    ll P = perimeter(rec[1]) + perimeter(rec[2]) + perimeter(rec[3]) - perimeter(u1) - perimeter(u2) - perimeter(u3) + perimeter(u4);

    cout << A << ' ' << P;

    return 0;
}