Zefirkash commited on
Commit
ebe26fe
·
verified ·
1 Parent(s): 19282ff

Create Fug.py

Browse files
Files changed (1) hide show
  1. Fug.py +41 -0
Fug.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ def can_divide_figures(n, figures):
2
+ possible_x = None
3
+ possible_y = None
4
+
5
+ for figure in figures:
6
+ if figure[0] == 0: # Круг
7
+ _, r, x, y = figure
8
+ cx, cy = x, y
9
+ else: # Прямоугольник
10
+ _, x1, y1, x2, y2, x3, y3, x4, y4 = figure
11
+ # Проверяем, какие стороны горизонтальные или вертикальные
12
+ if x1 == x2: # (x1, y1) - (x2, y2) вертикальная сторона
13
+ cx = (x1 + x3) // 2
14
+ cy = (y1 + y2) // 2
15
+ else: # (x1, y1) - (x4, y4) горизонтальная сторона
16
+ cx = (x1 + x2) // 2
17
+ cy = (y1 + y3) // 2
18
+
19
+ # Проверяем согласованность x и y
20
+ if possible_x is None:
21
+ possible_x = cx
22
+ elif possible_x != cx:
23
+ possible_x = None
24
+
25
+ if possible_y is None:
26
+ possible_y = cy
27
+ elif possible_y != cy:
28
+ possible_y = None
29
+
30
+ if possible_x is None and possible_y is None:
31
+ return "No"
32
+
33
+ return "Yes"
34
+
35
+
36
+ # Чтение входных данных
37
+ n = int(input().strip())
38
+ figures = [list(map(int, input().strip().split())) for _ in range(n)]
39
+
40
+ # Вывод результата
41
+ print(can_divide_figures(n, figures))