Cod sursa(job #3217734)

Utilizator vladdobro07vladdd vladdobro07 Data 24 martie 2024 14:50:49
Problema Reuniune Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.15 kb
#include <bits/stdc++.h>
#define ll long long

using namespace std;

ifstream fin("reuniune.in");
ofstream fout("reuniune.out");

struct dreptung {
        ll x1, x2, y1, y2;

        dreptung() {};

        ll perimetru() {
                return max(0ll, 2 * ((x2 - x1) + (y2 - y1)));
        }

        ll arie() {
                return max(0ll, (x2 - x1) * (y2 - y1));
        }

        dreptung operator &(dreptung other) {
                dreptung rez;
                rez.x1 = max(x1, other.x1);
                rez.x2 = min(x2, other.x2);
                rez.y1 = max(y1, other.y1);
                rez.y2 = min(y2, other.y2);
                return rez;
        }
};

signed main() {
        dreptung a, b, c;
        cin >> a.x1 >> a.y1 >> a.x2 >> a.y2 >> b.x1 >> b.y1 >> b.x2 >> b.y2 >> c.x1 >> c.y1 >> c.x2 >> c.y2;
        cout << a.arie() + b.arie() + c.arie() - (a & b).arie() - (c & b).arie() - (a & c).arie() + ((a & b) & c).arie() << " ";
        cout << a.perimetru() + b.perimetru() + c.perimetru() - (a & b).perimetru() - (c & b).perimetru() - (a & c).perimetru() + ((a & b) & c).perimetru() << "\n";
        return 0;
}