Cod sursa(job #3279243)

Utilizator Ilinca_Radu_2022Radu Ilinca-Rucsandra Ilinca_Radu_2022 Data 22 februarie 2025 11:31:46
Problema Reuniune Scor 90
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.1 kb
#include <bits/stdc++.h>
using namespace std;
ifstream fin("reuniune.in");
ofstream fout("reuniune.out");
long long i, a[5], b[5], c[5], d[5], x[5], y[5], z[5], t[5], maxix, minix, miniy, maxiy, s, p;
int main()
{
    for (i=1; i<=3; i++) fin>>a[i]>>b[i]>>c[i]>>d[i];

    for (i=1; i<=3; i++) {
        minix=min(minix, a[i]);
        maxix=max(maxix, c[i]);
        miniy=min(miniy, b[i]);
        maxiy=max(maxiy, d[i]);
    }
    p=(maxix-minix)+(maxiy-miniy);

    for (i=1; i<=3; i++) s+=abs(c[i]-a[i])*abs(d[i]-b[i]);

    x[1]=max(a[1], a[2]);
    z[1]=min(c[1], c[2]);
    y[1]=max(b[1], b[2]);
    t[1]=min(d[1], d[2]);

    x[2]=max(a[1], a[3]);
    z[2]=min(c[1], c[3]);
    y[2]=max(b[1], b[3]);
    t[2]=min(d[1], d[3]);

    x[3]=max(a[3], a[2]);
    z[3]=min(c[3], c[2]);
    y[3]=max(b[3], b[2]);
    t[3]=min(d[3], d[2]);

    for (i=1; i<=3; i++) s-=abs(x[i]-z[i])*abs(y[i]-t[i]);

    x[4]=max(x[3], x[2]);
    z[4]=min(z[3], z[2]);
    y[4]=max(y[3], y[2]);
    t[4]=min(t[3], t[2]);

    s+=abs(x[4]-z[4])*abs(y[4]-t[4]);

    fout<<s<<' '<<p*2;
    return 0;
}