Cod sursa(job #1522029)

Utilizator DeehoroEjkoliPop Darian DeehoroEjkoli Data 11 noiembrie 2015 08:43:02
Problema Reuniune Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.85 kb
#include <fstream>
#include <cmath>
#include <iostream>
using namespace std;
ifstream fin("patrat2.in");
ofstream fout("patrat2.out");

int xOne0, yOne0, xOne1, yOne1;
int xTwo0, yTwo0, xTwo1, yTwo1;
int xThree0, yThree0, xThree1, yThree1;

int maximum(int a, int b, int c) {
    return max(max(a, b), c);
}

int minimum(int a, int b, int c) {
    return min(min(a, b), c);
}

void reading() {
    fin >> xOne0 >> yOne0 >> xOne1 >> yOne1;
    fin >> xTwo0 >> yTwo0 >> xTwo1 >> yTwo1;
    fin >> xThree0 >> yThree0 >> xThree1 >> yThree1;
}

int main()
{
    reading();
    int reunionX, reunionY;
    reunionX = minimum(xOne1, xTwo1, xThree1) - maximum(xOne0, xTwo0, xThree0);
    if (reunionX < 0)
        reunionX = 0;
    reunionY = minimum(yOne1, yTwo1, yThree1) - maximum(yOne0, yTwo0, yThree0);
    if (reunionY < 0)
        reunionY = 0;
    int arieABC, arieAB, arieBC, arieAC;
    arieABC = reunionX * reunionY;
    int reunionXab, reunionXbc, reunionXac, reunionYab, reunionYbc, reunionYac;
    reunionXab = min(xOne1, xTwo1) - max(xOne0, xTwo0);
    if (reunionXab < 0)
        reunionXab = 0;
    reunionYab = min(yOne1, yTwo1) - max(yOne0, yTwo0);
    if (reunionYab < 0)
        reunionYab = 0;
    arieAB = reunionXab * reunionYab;

    reunionXbc = min(xTwo1, xThree1) - max(xTwo0, xThree0);
    if (reunionXbc < 0)
        reunionXbc = 0;
    reunionYbc = min(yTwo1, yThree1) - max(yTwo0, yThree0);
    if (reunionYbc < 0)
        reunionYbc = 0;
    arieBC = reunionXbc * reunionYbc;

    reunionXac = min(xOne1, xThree1) - max(xOne0, xThree0);
    if (reunionXac < 0)
        reunionXac = 0;
    reunionYac = min(yOne1, yThree1) - max(yOne0, yThree0);
    if (reunionYac < 0)
        reunionYac = 0;
    arieAC = reunionXac * reunionYac;
    cout << arieAC << " " << arieAB << " " << arieBC << " " << arieABC;
}