Pagini recente » Cod sursa (job #1553190) | Cod sursa (job #2533756) | Cod sursa (job #2527934) | Cod sursa (job #984615) | Cod sursa (job #2450556)
#include <bits/stdc++.h>
using namespace std;
///
typedef long long ll;
struct Rectangle{
ll x1, x2, y1, y2;
ll a, p;
void cn();
};
///
Rectangle r1, r2, r3, r12, r23, r13, r123;
ll perimeter, area;
///
void read();
void solve();
void write();
Rectangle unite(Rectangle ra, Rectangle rb);
///
int main()
{
read();
solve();
write();
return 0;
}
void read(){
freopen("reuniune.in", "r", stdin);
r1.cn(); r2.cn(); r3.cn();
fclose(stdin);
}
void solve(){
area=perimeter=0LL;
r12=unite(r1, r2);
r13=unite(r1, r3);
r23=unite(r2, r3);
r123=unite(r12, r3);
area+=r1.a+r2.a+r3.a+r123.a;
perimeter+=r1.p+r2.p+r3.p+r123.p;
area=area-r12.a-r13.a-r23.a;
perimeter=perimeter-r12.p-r13.p-r23.p;
}
void write(){
freopen("reuniune.out", "w", stdout);
printf("%lld %lld", area, perimeter);
fclose(stdout);
}
void Rectangle::cn(){
scanf("%lld%lld%lld%lld", &x1, &y1, &x2, &y2);
a=(x2-x1)*(y2-y1);
p=2*(x2-x1+y2-y1);
}
Rectangle unite(Rectangle ra, Rectangle rb){
Rectangle r;
r.x1=max(ra.x1, rb.x1);
r.x2=min(ra.x2, rb.x2);
r.y1=max(ra.y1, rb.y1);
r.y2=min(ra.y2, rb.y2);
ll w, h;
w=r.x2-r.x1;
h=r.y2-r.y1;
if(w<=0 || h<=0) r.a=0;
else r.a=w*h;
if(w<0 || h<0) r.p=0;
else r.p=2*(w+h);
return r;
}