Pagini recente » Cod sursa (job #1979792) | Cod sursa (job #1409971) | Cod sursa (job #1182731) | Cod sursa (job #256818) | Cod sursa (job #2877614)
#include <fstream>
#include <algorithm>
#include <stack>
#define int long long
using namespace std;
struct drept
{
int x0, y0, x1, y1;
int arie()
{
return (x1 - x0) * (y1 - y0);
}
int peri()
{
return 2 * (x1 - x0 + y1 - y0);
}
bool check()
{
return !(x0 == x1
and x1 == y1
and y1 == y0
and y0 == 0);
}
};
drept in2(drept a, drept b)
{
drept ans;
int mny = max(a.y0, b.y0);
if (mny > a.y1)
{
ans.x0 = ans.x1 = ans.y1 = ans.y0 = 0;
return ans;
}
int mnx = max(a.x0, b.x0);
if (mnx > a.x1)
{
ans.x0 = ans.x1 = ans.y1 = ans.y0 = 0;
return ans;
}
int mxx = min(a.x1, b.x1);
int mxy = min(a.y1, b.y1);
ans.x0 = mnx;
ans.y0 = mny;
ans.x1 = mxx;
ans.y1 = mxy;
return ans;
}
drept in3(drept a, drept b, drept c)
{
drept ans = in2(a, b);
if (!ans.check())
{
ans.x0 = ans.x1 = ans.y1 = ans.y0 = 0;
return ans;
}
ans = in2(ans, c);
if (!ans.check())
ans.x0 = ans.x1 = ans.y1 = ans.y0 = 0;
return ans;
}
signed main()
{
ifstream cin("reuniune.in");
ofstream cout("reuniune.out");
drept a, b, c;
cin >> a.x0 >> a.y0 >> a.x1 >> a.y1;
cin >> b.x0 >> b.y0 >> b.x1 >> b.y1;
cin >> c.x0 >> c.y0 >> c.x1 >> c.y1;
cout << a.arie() + b.arie() + c.arie() - in2(a, b).arie()
- in2(a, c).arie() - in2(b, c).arie() + in3(a, b, c).arie()
<< " ";
cout << a.peri() + b.peri() + c.peri() - in2(a, b).peri()
- in2(a, c).peri() - in2(b, c).peri() + in3(a, b, c).peri();
}