Pagini recente » Cod sursa (job #2900007) | Cod sursa (job #2572724) | Cod sursa (job #2293305) | Cod sursa (job #145888) | Cod sursa (job #782713)
Cod sursa(job #782713)
#include<cstdio>
#include<cassert>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
class rect{
public:
int x1, y1, x2, y2;
rect inters(rect other){
vector<int> x, y;
x.push_back(x1);x.push_back(x2);x.push_back(other.x1);x.push_back(other.x2);
y.push_back(y1);y.push_back(y2);y.push_back(other.y1);y.push_back(other.y2);
sort(x.begin(),x.end());
sort(y.begin(),y.end());
rect ans;
ans.x1 = x[1];
ans.x2 = x[2];
ans.y1 = y[1];
ans.y2 = y[2];
return ans;
}
long long area(){
return (long long)(x2 - x1) * (y2 - y1);
}
long long perim(){
return (long long) x2 - x1 + x2 - x1 + y2 - y1 + y2 - y1;
}
};
int main(){
assert(freopen("reuniune.in", "r", stdin));
assert(freopen("reuniune.out", "w", stdout));
long long ans = 0;
rect one, two, three;
scanf("%d%d%d%d%d%d%d%d%d%d%d%d",&one.x1,&one.y1,&one.x2,&one.y2,&two.x1,&two.y1,&two.x2,&two.y2,&three.x1,&three.y1,&three.x2,&three.y2);
ans = one.area() + two.area() + three.area();
rect in1, in2, in3, in4;
in1 = one.inters(one.inters(two));
in2 = one.inters(one.inters(three));
in3 = two.inters(two.inters(three));
in4 = in1.inters(in1.inters(in2));
ans -= in1.area() + in2.area() + in3.area() - in4.area();
long long per;
per = one.perim() + two.perim() + three.perim() - in1.perim() - in2.perim() - in3.perim() + in4.perim();
printf("%lld %lld",ans, per);
return 0;
}