Pagini recente » Cod sursa (job #750155) | Cod sursa (job #49773) | Cod sursa (job #2957264) | Cod sursa (job #1210000) | Cod sursa (job #1527169)
#include<fstream>
#include<cmath>
using namespace std;
struct coordonate
{
int josX;
int josY;
int susX;
int susY;
}drept1,drept2,drept3;
int main()
{
ifstream f("reuniune.in");
ofstream g("reuniune.out");
f>>drept1.josX>>drept1.josY>>drept1.susX>>drept1.susY;
f>>drept2.josX>>drept2.josY>>drept2.susX>>drept2.susY;
f>>drept3.josX>>drept3.josY>>drept3.susX>>drept3.susY;
int reSX12=max(drept1.josX,drept2.josX);
int reDX12=min(drept1.susX,drept2.susX);
int reJY12=max(drept1.josY,drept2.josY);
int reSY12=min(drept1.susY,drept2.susY);
int aRe12=(abs(reDX12-reSX12))*(abs(reSY12-reJY12));
int pRe12=abs(reDX12-reSX12)+abs(reSY12-reJY12);
if(reSX12>=reDX12||reJY12>=reSY12){aRe12=0; pRe12=0;}
int reSX13=max(drept1.josX,drept3.josX);
int reDX13=min(drept1.susX,drept3.susX);
int reJY13=max(drept1.josY,drept3.josY);
int reSY13=min(drept1.susY,drept3.susY);
int aRe13=(abs(reDX13-reSX13))*(abs(reSY13-reJY13));
int pRe13=abs(reDX13-reSX13)+abs(reSY13-reJY13);
if(reSX13>=reDX13||reJY13>=reSY13){aRe13=0; pRe13=0;}
int reSX23=max(drept2.josX,drept3.josX);
int reDX23=min(drept2.susX,drept3.susX);
int reJY23=max(drept2.josY,drept3.josY);
int reSY23=min(drept2.susY,drept3.susY);
int aRe23=(abs(reDX23-reSX23))*(abs(reSY23-reJY23));
int pRe23=abs(reDX23-reSX23)+abs(reSY23-reJY23);
if(reSX23>reDX23||reJY23>reSY23){aRe23=0; pRe23=0;}
int reSX123=max(max(drept2.josX,drept3.josX),drept1.josX);
int reDX123=min(min(drept2.susX,drept3.susX),drept1.susX);
int reJY123=max(max(drept2.josY,drept3.josY),drept1.josY);
int reSY123=min(min(drept2.susY,drept3.susY),drept1.susY);
int aRe123=(abs(reDX123-reSX123))*(abs(reSY123-reJY123));
int pRe123=abs(reDX123-reSX123)+abs(reSY123-reJY123);
if(reSX123>=reDX123||reJY123>=reSY123){aRe123=0; pRe123=0;}
int a1=(abs(drept1.susX-drept1.josX))*(abs(drept1.susY-drept1.josY));
int a2=(abs(drept2.susX-drept2.josX))*(abs(drept2.susY-drept2.josY));
int a3=(abs(drept3.susX-drept3.josX))*(abs(drept3.susY-drept3.josY));
int aTot=a1+a2+a3-aRe12-aRe13-aRe23+aRe123;
g<<aTot<<" ";
int p1=abs(drept1.susX-drept1.josX)+abs(drept1.susY-drept1.josY);
int p2=abs(drept2.susX-drept2.josX)+abs(drept2.susY-drept2.josY);
int p3=abs(drept3.susX-drept3.josX)+abs(drept3.susY-drept3.josY);
int pTot=p1+p2+p3-pRe12-pRe13-pRe23+pRe123;
g<<2*pTot;
return 0;
}