Pagini recente » Cod sursa (job #1612639) | Cod sursa (job #1345899) | Cod sursa (job #162677) | Cod sursa (job #1909451) | Cod sursa (job #1223716)
#include <cstdio>
#include <cmath>
#include <algorithm>
#define NMAX 4
using namespace std;
struct reun{
int x1;
int y1;
int x2;
int y2;
};
reun v[NMAX];
inline long long solve(reun a){
return (1LL) * fabs(a.x2 - a.x1) * fabs(a.y2 - a.y1);
}
inline long long solve2(reun a){
return (1LL) * (fabs(a.x2 - a.x1) + fabs(a.y2 - a.y1)) * 2;
}
reun intersect(reun a, reun b){
reun c;
c.x1 = max(a.x1, b.x1);
c.x2 = min(a.x2, b.x2);
c.y1 = max(a.y1, b.y1);
c.y2 = min(a.y2, b.y2);
if(c.x1 > c.x2){
c.x1 = c.x2 = c.y1 = c.y2 = 0;
return c;
}
return c;
}
int main(){
freopen("reuniune.in", "r", stdin);
freopen("reuniune.out", "w", stdout);
long long Ans = 0, Ans2 = 0;
for(int i = 1; i <= 3; ++i){
scanf("%d %d %d %d", &v[i].x1, &v[i].y1, &v[i].x2, &v[i].y2);
Ans += (1LL) * solve(v[i]);
Ans2 += (1LL) * solve2(v[i]);
}
for(int i = 1; i <= 3; ++i)
for(int j = i + 1; j <= 3; ++j){
Ans -= (1LL) * solve(intersect(v[i], v[j]));
Ans2 -= (1LL) * solve2(intersect(v[i], v[j]));
}
Ans += (1LL) * solve(intersect(intersect(v[1], v[2]), v[3]));
Ans2 += (1LL) * solve2(intersect(intersect(v[1], v[2]), v[3]));
printf("%lld %lld\n", Ans, Ans2);
return 0;
}