Pagini recente » Rating IDKIDKIDKDIKD (Teodora67) | Cod sursa (job #2196751) | Cod sursa (job #2284265)
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ifstream f("reuniune.in");
ofstream g("reuniune.out");
struct abi
{
ll lin1;
ll lin2;
ll col1;
ll col2;
}d[4];
ll Arie(abi a)
{
return (a.lin2-a.lin1)*(a.col2-a.col1);
}
ll Perimetru (abi a)
{
return 2 * ((a.lin2-a.lin1)+(-1)*(a.col1-a.col2));
}
abi inters(abi a , abi b)
{
abi c,d;
c.lin1 = max(a.lin1 , b.lin1);
c.col1 = max(a.col1 , b.col1);
c.lin2 = min (a.lin2 , b.lin2);
c.col2 = min (a.col2 , b.col2);
if (c.lin1 <= c.lin2 && c.col1 <= c.col2) return c;
else d.lin1 = d.lin2 = d.col1 = d.col2 = 0 ;
return d;
}
int main()
{
for (ll i = 1 ; i <= 3 ; i ++ ) f >> d[i].lin1 >> d[i].col1 >> d[i].lin2 >> d[i].col2;
g << Arie(d[1]) + Arie(d[2]) + Arie(d[3]) - Arie(inters(d[1],d[2])) - Arie(inters(d[2], d[3])) - Arie(inters(d[3],d[1])) + Arie (inters(inters(d[1],d[2]),d[3]));
g << ' ';
g << Perimetru(d[1]) + Perimetru(d[2]) + Perimetru(d[3]) - Perimetru(inters(d[1],d[2])) - Perimetru(inters(d[2], d[3])) - Perimetru(inters(d[3],d[1])) + Perimetru(inters(inters(d[1],d[2]),d[3]));
return 0;
}