Cod sursa(job #1676246)

Utilizator refugiatBoni Daniel Stefan refugiat Data 5 aprilie 2016 19:54:15
Problema Reuniune Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.22 kb
#include <iostream>
#include <fstream>
#define ull unsigned long long
#define ll long long
using namespace std;
ifstream si("reuniune.in");
ofstream so("reuniune.out");
ll v[5][5];

int main()
{
    int i,j;
    for(i=0;i<3;++i)
    {
        for(j=0;j<4;++j)
            si>>v[i][j];
    }
    ll ar=0;
    ll per=0;
    ll x1,x2,y1,y2;
    int cont;
    for(i=1;i<=7;++i)
    {
        cont=0;
        x2=1000000001;
        y2=x2;
        x1=0-x2;
        y1=0-x2;
        for(j=0;j<3;++j)
        {
            if(i&(1<<j))
            {
                x1=max(x1,v[j][0]);
                y1=max(y1,v[j][1]);
                x2=min(x2,v[j][2]);
                y2=min(y2,v[j][3]);
                ++cont;
            }
        }
        if(x1<=x2)
        {
            if(y1<=y2)
            {
                if(cont&1)
                {
                    ar+=1LL*(x2-x1)*(y2-y1);
                    per+=2LL*(x2-x1)+2LL*(y2-y1);
                }
                else
                {
                    ar-=1LL*(x2-x1)*(y2-y1);
                    per-=2LL*(x2-x1)+2LL*(y2-y1);
                }
            }
        }
    }

    so<<ar<<' '<<per<<'\n';
    return 0;
}