Cod sursa(job #602202)

Utilizator Smaug-Andrei C. Smaug- Data 9 iulie 2011 18:36:45
Problema Reuniune Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.94 kb
#include <cstdio>
#include <algorithm>
using namespace std;

typedef long long ll;

typedef struct square {
  ll ax, ay, bx, by;
} square;

inline ll s(square X){
  return (X.bx-X.ax)*(X.by-X.ay);
}

inline ll p(square X){
  return (2LL*(X.bx-X.ax)+2LL*(X.by-X.ay));
}

inline square i(square X, square Y){
  
  square R;
  R.ax=max(X.ax, Y.ax);
  R.ay=max(X.ay, Y.ay);
  R.bx=min(X.bx, Y.bx);
  R.by=min(X.by, Y.by);

  if(R.ax > R.bx || R.ay > R.by)
    R.ax=R.ay=R.bx=R.by=0;

  return R;

}


int main(){

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

  square A, B, C;

  scanf("%lld%lld%lld%lld", &A.ax, &A.ay, &A.bx, &A.by);
  scanf("%lld%lld%lld%lld", &B.ax, &B.ay, &B.bx, &B.by);
  scanf("%lld%lld%lld%lld", &C.ax, &C.ay, &C.bx, &C.by);

  
  printf("%lld ",  s(A)+s(B)+s(C)-s(i(A,B))-s(i(A,C))-s(i(B,C))+s(i(i(A,B),C)));
  printf("%lld\n", p(A)+p(B)+p(C)-p(i(A,B))-p(i(A,C))-p(i(B,C))+p(i(i(A,B),C)));

  return 0;

}