Pagini recente » Cod sursa (job #3314670) | Cod sursa (job #3314669) | Cod sursa (job #3333806) | Cod sursa (job #3340333) | Cod sursa (job #3314664)
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
ifstream fin("reuniune.in");
ofstream fout("reuniune.out");
struct coord
{
int x0, y0, x1, y1;
};
vector<coord> v;
int calcarie(const vector<int>& ind)
{
int x0 = -1e9, y0 = -1e9, x1 = 1e9, y1 = 1e9;
for (int idx : ind)
{
const coord& r = v[idx];
x0 = max(x0, r.x0);
y0 = max(y0, r.y0);
x1 = min(x1, r.x1);
y1 = min(y1, r.y1);
}
if (x0 >= x1 || y0 >= y1)
return 0;
return (x1 - x0) * (y1 - y0);
}
int calcperim(const vector<int>& ind)
{
int x0 = -1e9, y0 = -1e9, x1 = 1e9, y1 = 1e9;
for (int idx : ind)
{
const coord& r = v[idx];
x0 = max(x0, r.x0);
y0 = max(y0, r.y0);
x1 = min(x1, r.x1);
y1 = min(y1, r.y1);
}
if (x0 >= x1 || y0 >= y1)
return 0;
return (x1 - x0)*2 +2*(y1 - y0);
}
void pinex(long long &s, long long &p)
{
int lim=1<<3;
for (int i=1; i<lim; ++i)
{
vector <int> ind;
for (int j=0; j<3; ++j)
if (i&(1<<j))
ind.push_back(j);
long long area = calcarie(ind);
long long perim= calcperim(ind);
if (ind.size() % 2 == 1)
{
s=s+area;
p=p+perim;
}
else
{
s=s-area;
p=p-perim;
}
}
}
int main()
{
v.resize(3);
for (int i = 0; i < 3; ++i)
fin >> v[i].x0 >> v[i].y0 >> v[i].x1 >> v[i].y1;
long long s=0,p=0;
pinex(s,p);
fout << s << " " << p;
return 0;
}