325A.md (1522B)
1 Source: https://codeforces.com/problemset/problem/325/A 2 3 A. Square and Rectangles 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 stdin 16 17 output 18 19 stdout 20 21 You are given *n* rectangles. The corners of rectangles have integer coordinates and their edges are parallel to the *Ox* and *Oy* axes. The rectangles may touch each other, but they do not overlap (that is, there are no points that belong to the interior of more than one rectangle). 22 23 Your task is to determine if the rectangles form a square. In other words, determine if the set of points inside or on the border of at least one rectangle is precisely equal to the set of points inside or on the border of some square. 24 25 Input 26 27 The first line contains a single integer *n* (1 ≤ *n* ≤ 5). Next *n* lines contain four integers each, describing a single rectangle: *x*1, *y*1, *x*2, *y*2 (0 ≤ *x*1 < *x*2 ≤ 31400, 0 ≤ *y*1 < *y*2 ≤ 31400) — *x*1 and *x*2 are *x*-coordinates of the left and right edges of the rectangle, and *y*1 and *y*2 are *y*-coordinates of the bottom and top edges of the rectangle. 28 29 No two rectangles overlap (that is, there are no points that belong to the interior of more than one rectangle). 30 31 Output 32 33 In a single line print "YES", if the given rectangles form a square, or "NO" otherwise. 34 35 Examples 36 37 Input 38 39 ``` 40 5 41 0 0 2 3 42 0 3 3 5 43 2 0 5 2 44 3 2 5 5 45 2 2 3 3 46 ``` 47 48 Output 49 50 ``` 51 YES 52 ``` 53 54 Input 55 56 ``` 57 4 58 0 0 2 3 59 0 3 3 5 60 2 0 5 2 61 3 2 5 5 62 ``` 63 64 Output 65 66 ``` 67 NO 68 ```