-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswea_4836.py
More file actions
44 lines (38 loc) · 1.17 KB
/
Copy pathswea_4836.py
File metadata and controls
44 lines (38 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
def coloring(start_c, start_r, end_c, end_r, color):
red_blocks = []
blue_blocks = []
for i in range(start_c, end_c + 1):
for j in range(start_r, end_r + 1):
if color == 1:
red_blocks.append([i, j])
else:
blue_blocks.append([i, j])
if color == 1:
return red_blocks
else:
return blue_blocks
def find_purple_blocks(red_b, blue_b):
count = 0
if len(red_b) > len(blue_b):
for blocks in blue_b:
if blocks in red_b:
count += 1
else:
for blocks in red_b:
if blocks in blue_b:
count += 1
return count
# 원하는 출력이 나오려면 어떻게 해야 할지 고민하기
t = int(input())
for tc in range(1, t + 1):
n = int(input())
red_blocks = []
blue_blocks = []
for i in range(n):
r1, c1, r2, c2, color = map(int, input().split())
if color == 1:
red_blocks.extend(coloring(r1, c1, r2, c2, color))
else:
blue_blocks.extend(coloring(r1, c1, r2, c2, color))
result = find_purple_blocks(red_blocks, blue_blocks)
print(f'#{tc} {result}')