Pagini recente » Cod sursa (job #1333795) | Cod sursa (job #1692451) | Cod sursa (job #3225117) | Cod sursa (job #337661) | Cod sursa (job #2419569)
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> per;
typedef long double LD;
const int N=100005;
const int M=1005;
const LL mod=1000000007;
const int inf=(1<<30);
const LL linf=(1LL<<61);
ifstream f("reuniune.in");
ofstream g("reuniune.out");
///LONG LONG
struct drept{
int x1,y1,x2,y2;
}v[5];
int Ar,P;
bool unite(drept&A,drept B)
{
if(B.x1<A.x1) swap(A,B);
else if(A.x1==B.x1 && B.y1<A.y1) swap(A,B);
if(A.y2<B.y1) return 1;
if(A.x2<B.x1) return 1;
A.x1=max(A.x1,B.x1); A.y1=max(A.y1,B.y1);
A.x2=min(A.x2,B.x2); A.y2=min(A.y2,B.y2);
return 0;
}
void doua(drept A,drept B)
{
if(unite(A,B)) return;
Ar-=(A.x2-A.x1)*(A.y2-A.y1);
P-=2*(A.x2-A.x1+A.y2-A.y1);
}
void all(drept A,drept B,drept C)
{
if(unite(A,B) || unite(A,C)) return;
Ar+=(A.x2-A.x1)*(A.y2-A.y1);
P+=2*(A.x2-A.x1+A.y2-A.y1);
}
void arie()
{
///sigma 1
for(int i=1;i<=3;++i) Ar+=(v[i].x2-v[i].x1)*(v[i].y2-v[i].y1), P+=2*(v[i].x2-v[i].x1+v[i].y2-v[i].y1);
///sigma 2
for(int i=1;i<=2;++i) for(int j=i+1;j<=3;++j) doua(v[i],v[j]);
///sigma 3
all(v[1],v[2],v[3]);
g<<Ar<<' '<<P;
}
int main()
{
for(int i=1;i<=3;++i) f>>v[i].x1>>v[i].y1>>v[i].x2>>v[i].y2;
arie();
return 0;
}