Cod sursa(job #1675978)

Utilizator refugiatBoni Daniel Stefan refugiat Data 5 aprilie 2016 17:49:12
Problema Reuniune Scor 90
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.18 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];
    }
    ull 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;
            }
        }
        //cout<<i<<' '<<x1<<' '<<y1<<' '<<x2<<' '<<y2<<'\n';
        if(x2>x1&&y2>y1)
        {
            if(cont&1)
            {
                ar+=1ULL*(x2-x1)*(y2-y1);
                per+=(x2-x1+y2-y1)*2;
            }
            else
            {
                ar-=1ULL*(x2-x1)*(y2-y1);
                per-=(x2-x1+y2-y1)*2;
            }
        }
    }

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