Cod sursa(job #1364661)

Utilizator Theodor1000Cristea Theodor Stefan Theodor1000 Data 27 februarie 2015 19:28:44
Problema Reuniune Scor 80
Compilator cpp Status done
Runda Arhiva de probleme Marime 2.01 kb
#include <cstdio>
#include <algorithm>

using namespace std;

int c[4][8];

int main ()
{
    freopen ("reuniune.in", "r", stdin);
    freopen ("reuniune.out", "w", stdout);

    for (int i = 1; i <= 3; ++i)
        for (int j = 1; j <= 4; ++j)
            scanf ("%d", &c[i][j]);

    long long s1 = 1LL * (c[1][3] - c[1][1]) * (c[1][4] - c[1][2]);
    long long s2 = 1LL * (c[2][3] - c[2][1]) * (c[2][4] - c[2][2]);
    long long s3 = 1LL * (c[3][3] - c[3][1]) * (c[3][4] - c[3][2]);

    long long s12 = 1LL * (min (c[1][4], c[2][4]) - max (c[1][2], c[2][2])) * (min (c[1][3], c[2][3]) - max (c[1][1], c[2][1]));
    long long s23 = 1LL * (min (c[3][4], c[2][4]) - max (c[3][2], c[2][2])) * (min (c[3][3], c[2][3]) - max (c[3][1], c[2][1]));
    long long s13 = 1LL * (min (c[1][4], c[3][4]) - max (c[1][2], c[3][2])) * (min (c[1][3], c[3][3]) - max (c[1][1], c[3][1]));

    long long s123 = 1LL * (min (min (c[1][4], c[2][4]), c[3][4]) - max (max (c[1][2], c[2][2]), c[3][2])) * (min (min (c[1][3], c[2][3]), c[3][3]) -max (c[1][1], c[2][1]));

    s12 = s1 + s2 + s3 - s12 - s23 - s13 + s123;
    printf ("%lld ", s12);

    s1 = 2LL * (1LL * (c[1][3] - c[1][1]) + 1LL * (c[1][4] - c[1][2]));
    s2 = 2LL * (1LL * (c[2][3] - c[2][1]) + 1LL * (c[2][4] - c[2][2]));
    s3 = 2LL * (1LL * (c[3][3] - c[3][1]) + 1LL * (c[3][4] - c[3][2]));

    s12 = 2LL * (1LL * (min (c[1][4], c[2][4]) - max (c[1][2], c[2][2])) + 1LL * (min (c[1][3], c[2][3]) - max (c[1][1], c[2][1])));
    s23 = 2LL * (1LL * (min (c[3][4], c[2][4]) - max (c[3][2], c[2][2])) + 1LL * (min (c[3][3], c[2][3]) - max (c[3][1], c[2][1])));
    s13 = 2LL * (1LL * (min (c[1][4], c[3][4]) - max (c[1][2], c[3][2])) + 1LL * (min (c[1][3], c[3][3]) - max (c[1][1], c[3][1])));

    s123 = 2LL * (1LL * (min (min (c[1][4], c[2][4]), c[3][4]) - max (max (c[1][2], c[2][2]), c[3][2])) + 1LL * (min (min (c[1][3], c[2][3]), c[3][3]) -max (c[1][1], c[2][1])));

    s12 = s1 + s2 + s3 - s12 - s23 - s13 + s123;
    printf ("%lld\n", s12);

    return 0;
}