예제 #1
0
 int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {
     int x1 = abs(B - D), y1 = abs(A - C);
     int x2 = abs(F - H), y2 = abs(E - G);
     
     int x3 = getIntersectionLength(min(B, D), max(B, D), min(F, H), max(F, H));
     int y3 = getIntersectionLength(min(A, C), max(A, C), min(E, G), max(E, G));
     
     long long result = 0;
     result += (long long)x1 * y1;
     result += (long long)x2 * y2;
     result -= (long long)x3 * y3;
     
     return (int)result;
 }
예제 #2
0
 int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {
   return (C - A) * (D - B) + (G - E) * (H - F) - getIntersectionLength(A, C, E, G) * getIntersectionLength(B, D, F, H); 
 }