Cod sursa(job #3217738)

Utilizator vladdobro07vladdd vladdobro07 Data 24 martie 2024 14:55:06
Problema Reuniune Scor 90
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.41 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 x, ll y, ll X, ll Y) {
                x1 = x;
                x2 = X;
                y1 = y;
                y2 = Y;
        }

        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);
                if(x2 < x1 || y2 < y1)
                        return dreptung(0ll, 0ll, 0ll, 0ll);
                return rez;
        }
};

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