Cod sursa(job #1901668)

Utilizator darisavuSavu Daria darisavu Data 4 martie 2017 10:16:26
Problema Reuniune Scor 90
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.02 kb
#include <fstream>
using namespace std;
ifstream f("reuniune.in");
ofstream g("reuniune.out");
long long x1,y1,z1,t1,x2,y2,z2,t2,x3,y3,z3,t3,l,l1,l2,l3,s,p;
int main()
{
    f>>x1>>y1>>z1>>t1>>x2>>y2>>z2>>t2>>x3>>y3>>z3>>t3;
    s=(z1-x1)*(t1-y1)+(z2-x2)*(t2-y2)+(z3-x3)*(t3-y3);
    p=2*(z1-x1)+2*(t1-y1)+2*(z2-x2)+2*(t2-y2)+2*(z3-x3)+2*(t3-y3);
    l=max(x1,x2);
    l1=max(y1,y2);
    l2=min(z1,z2);
    l3=min(t1,t2);
   if(l2>l&&l3>l1) {s=s-((l2-l)*(l3-l1));
    p=p-(2*(l2-l)+2*(l3-l1));}
    l=max(x1,x3);
    l1=max(y1,y3);
    l2=min(z1,z3);
    l3=min(t1,t3);
    if(l2>l&&l3>l1) {s=s-((l2-l)*(l3-l1));
    p=p-(2*(l2-l)+2*(l3-l1));}
    l=max(x2,x3);
    l1=max(y2,y3);
    l2=min(z2,z3);
    l3=min(t2,t3);
    if(l2>l&&l3>l1) {s=s-((l2-l)*(l3-l1));
    p=p-(2*(l2-l)+2*(l3-l1));}
    l=max(max(x1,x2),x3);
    l1=max(max(y1,y2),y3);
    l2=min(min(z1,z2),z3);
    l3=min(min(t1,t2),t3);
    if(l2>l&&l3>l1) {s=s+((l2-l)*(l3-l1));
    p=p+(2*(l2-l)+2*(l3-l1));}
     g<<s<<' '<<p;
    return 0;
}