import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// Rect rect1 = new Rect(0,0,10,10);
// Rect rect2 = new Rect(0,0,5,5);
// System.out.println(rect1.getRectArea(rect2));
Scanner scanner = new Scanner(System.in);
int num = scanner.nextInt();
int right_up_x = scanner.nextInt();
int right_up_y = scanner.nextInt();
Rect rect = new Rect(0,0,right_up_x,right_up_y);
List<Rect> rectList = new ArrayList<>();
for(int i = 0; i < num; i++){
int x1 = scanner.nextInt();
int y1 = scanner.nextInt();
int x2 = scanner.nextInt();
int y2 = scanner.nextInt();
Rect tmp = new Rect(x1,y1,x2,y2);
rectList.add(tmp);
}
int total = 0;
for(Rect recttmp : rectList){
int tmp = recttmp.getRectArea(rect);
total += tmp;
}
System.out.println(total);
}
}
class Rect {
int left_down_x;
int left_down_y;
int right_up_x;
int right_up_y;
public Rect(int left_down_x, int left_down_y, int right_up_x, int right_up_y) {
this.left_down_x = left_down_x;
this.left_down_y = left_down_y;
this.right_up_x = right_up_x;
this.right_up_y = right_up_y;
}
public int getRectArea(Rect other){
if(this.left_down_x >= other.right_up_x
|| other.left_down_x >= this.right_up_x
|| this.left_down_y >= other.right_up_y
|| other.left_down_y >= this.right_up_y){
return 0;
}
int sub_rect_left_down_x = Math.max(this.left_down_x, other.left_down_x);
int sub_rect_right_up_x = Math.min(this.right_up_x, other.right_up_x);
int sub_rect_left_down_y = Math.max(this.left_down_y, other.left_down_y);
int sub_rect_right_up_y = Math.min(this.right_up_y, other.right_up_y);
return (sub_rect_right_up_x-sub_rect_left_down_x)*(sub_rect_right_up_y-sub_rect_left_down_y);
}
}
ccf 202303-1田地丈量
最新推荐文章于 2024-10-06 20:16:20 发布