Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

63-tgyuuAn #216

Merged
merged 1 commit into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
---
Loading