Cod sursa(job #3175376)

Utilizator xXoctavianXxStanescu Matei Octavian xXoctavianXx Data 25 noiembrie 2023 18:22:25
Problema Reuniune Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.14 kb
#include <bits/stdc++.h>
#define int long long

using namespace std;

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

struct drept{
    int xj,yj,xs,ys;

    drept operator * (const drept &other)
    {
        return {max(xj,other.xj),max(yj,other.yj),min(xs,other.xs),min(ys,other.ys)};
    }
    int area()
    {
        if(xs < xj || ys < yj) return 0;
        return (xs - xj) * (ys - yj);
    }
    int perim()
    {
        if(xs < xj || ys < yj) return 0;
        return 2 * (xs - xj) + 2 * (ys - yj);
    }
} d[3];

pair<int,int> reuniuni(drept a, drept b, drept c)
{
    int aria = a.area() + b.area() + c.area();
    aria -= (a*b).area() + (a*c).area() + (b*c).area();
    aria += ((a * b) * c) .area();

    int perim = a.perim() + b.perim() + c.perim();
    perim -= (a*b).perim() + (a*c).perim() + (b*c).perim();
    perim += ((a * b) * c) .perim();
    return {aria,perim};
}

signed main()
{
    for(int i=0; i<3; i++)
    {
        fin>>d[i].xj>>d[i].yj>>d[i].xs>>d[i].ys;
    }
    pair<int,int> rasp = reuniuni(d[0],d[1],d[2]);
    fout<<rasp.first<<" "<<rasp.second;
    return 0;
}