Skip to content

Commit

Permalink
Merge pull request #216 from AlgoLeadMe/63-tgyuuAn
Browse files Browse the repository at this point in the history
63-tgyuuAn
  • Loading branch information
tgyuuAn authored Jul 14, 2024
2 parents 77123fe + f584fc3 commit 2472c41
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
59 changes: 59 additions & 0 deletions tgyuuAn/BFS/๋กœ๊ณ .py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import sys
from collections import deque

def input(): return sys.stdin.readline().rstrip()

N = int(input())

can_visit = set()
for _ in range(N):
x1, y1, x2, y2 = map(int,input().split())

x1 *= 2
y1 *= 2
x2 *= 2
y2 *= 2

for draw_x in range(x1, x2+1):
can_visit.add((draw_x, y1))
can_visit.add((draw_x, y2))

for draw_y in range(y1, y2+1):
can_visit.add((x1, draw_y))
can_visit.add((x2, draw_y))


dx = [0, 0, -1, 1]
dy = [-1, 1, 0, 0]
can_visit.add((0, 0))
draw_coordinate = deque(can_visit)
answer = 0
while draw_coordinate:
deq = deque()

if (0, 0) in can_visit:
deq.append((0, 0))
can_visit.discard((0, 0))

else:
now_x, now_y = draw_coordinate.popleft()
if (now_x, now_y) not in can_visit: continue

deq.append((now_x, now_y))
can_visit.discard((now_x, now_y))

while deq:
now_x, now_y = deq.popleft()

for dir in range(4):
new_x = now_x + dx[dir]
new_y = now_y + dy[dir]

if (new_x, new_y) not in can_visit: continue

can_visit.discard((new_x, new_y))
deq.append((new_x, new_y))

answer += 1

print(answer-1)
3 changes: 2 additions & 1 deletion tgyuuAn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,6 @@
| 59์ฐจ์‹œ | 2024.06.03 | ๋‹ค์ต์ŠคํŠธ๋ผ + ์ด๋ถ„ ํƒ์ƒ‰ | <a href="https://www.acmicpc.net/problem/14942">๊ฐœ๋ฏธ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/207
| 60์ฐจ์‹œ | 2024.06.07 | ๊ทธ๋ฆฌ๋”” | <a href="https://www.acmicpc.net/problem/14939">๋ถˆ ๋„๊ธฐ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/209
| 61์ฐจ์‹œ | 2024.06.20 | ํฌ๋ฃจ์Šค์นผ | <a href="https://www.acmicpc.net/problem/1774">์šฐ์ฃผ์‹ ๊ณผ์˜ ๊ต๊ฐ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/212
| 62์ฐจ์‹œ | 2024.07.01 | DP | <a href="https://www.acmicpc.net/problem/1949">์šฐ์ˆ˜ ๋งˆ์„</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/214
| 62์ฐจ์‹œ | 2024.07.01 | DP | <a href="https://www.acmicpc.net/problem/1949">์šฐ์ˆ˜ ๋งˆ์„</a> | https://github.com/AlgoLeadMe/AlgoLeadMse-1/pull/214
| 63์ฐจ์‹œ | 2024.07.08 | BFS | <a href="https://www.acmicpc.net/problem/3108">๋กœ๊ณ </a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/216
---

0 comments on commit 2472c41

Please sign in to comment.