Pagini recente » Cod sursa (job #1392064) | Cod sursa (job #778465) | Cod sursa (job #3283590) | Cod sursa (job #2178942) | Cod sursa (job #3257487)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("reuniune.in");
ofstream fout("reuniune.out");
struct Dreptunghi {
long long x0, y0, x1, y1;
Dreptunghi(long long _x0 = 0, long long _y0 = 0, long long _x1 = 0, long long _y1 = 0) {
x0 = _x0;
y0 = _y0;
x1 = _x1;
y1 = _y1;
}
long long Arie() {
return max(0, (x1 - x0) * (y1 - y0));
}
long long Perimetru() {
return max(0, 2 * (x1 - x0) + 2 * (y1 - y0));
}
} drept[3];
static inline Dreptunghi Intersect(Dreptunghi a, Dreptunghi b) {
long long x0 = max(a.x0, b.x0);
long long y0 = max(a.y0, b.y0);
long long x1 = min(a.x1, b.x1);
long long y1 = min(a.y1, b.y1);
return Dreptunghi(x0, y0, x1, y1);
}
int main() {
for(long long i = 0; i < 3; i++) fin >> drept[i].x0 >> drept[i].y0 >> drept[i].x1 >> drept[i].y1;
Dreptunghi d01 = Intersect(drept[0], drept[1]);
Dreptunghi d12 = Intersect(drept[1], drept[2]);
Dreptunghi d02 = Intersect(drept[0], drept[2]);
Dreptunghi d012 = Intersect(Intersect(drept[0], drept[1]), drept[2]);
fout << drept[0].Arie() + drept[1].Arie() + drept[2].Arie() - d01.Arie() - d12.Arie() - d02.Arie() + d012.Arie() << " ";
fout << drept[0].Perimetru() + drept[1].Perimetru() + drept[2].Perimetru() - d01.Perimetru() - d12.Perimetru() - d02.Perimetru() + d012.Perimetru();
return 0;
}