Skip to content

Commit

Permalink
2024-08-12
Browse files Browse the repository at this point in the history
  • Loading branch information
H0ngJu committed Aug 12, 2024
1 parent 0d211e0 commit bd62d9a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import sys
from collections import deque

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

t = int(input())
dx = [-1, 1, 0, 0]
dy = [0, 0, -1, 1]


for i in range(t):
n = int(input())
hx, hy = map(int, input().split())
store = [list(map(int, input().split())) for _ in range(n)]
fx, fy = map(int, input().split())

x, y = hx, hy
result = "sad"

q = deque([(x, y, 20)])
visited = set([x, y])

while q:
x, y, beer = q.popleft()

if abs(x-fx) + abs(y-fy) <= 50*beer: # ์ถ•์ œ๊นŒ์ง€ ๊ฐˆ ์ˆ˜ ์žˆ๋Š”์ง€
result = "happy"
break

for sx, sy in store: # ํŽธ์˜์  ๋“ค๋ฆด ์ˆ˜ ์žˆ๋Š”์ง€
if abs(x-sx) + abs(y-sy) <= 50 * beer and (sx, sy) not in visited:
visited.add((sx, sy))
q.append((sx, sy, 20))

if beer > 0: # beer ๋จน๊ณ  ๊ฐ€๊ธฐ
for i in range(4):
nx = x + dx[i]
ny = y + dy[i]

if (nx, ny) not in visited:
visited.add((nx, ny))
q.append((nx, ny, beer - 1))

print(result)

3 changes: 2 additions & 1 deletion H0ngJu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
| 18์ฐจ์‹œ | 2024.05.26 | DFS | [๊ณ„๋ž€์œผ๋กœ ๊ณ„๋ž€์น˜๊ธฐ](https://www.acmicpc.net/problem/16987) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/199 |
| 19์ฐจ์‹œ | 2024.05.31 | DP | [ํ•ฉ๋ถ„ํ•ด](https://www.acmicpc.net/problem/2225) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/202 |
| 20์ฐจ์‹œ | 2024.06.03 | ๋ฐฑํŠธ๋ž˜ํ‚น | [์Šคํƒ€ํŠธ์™€ ๋งํฌ](https://www.acmicpc.net/problem/14889) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/206 |
| 21์ฐจ์‹œ | 2024.06.07 | ๊ทธ๋ฆฌ๋”” | [ํ–‰๋ณต ์œ ์น˜์›](https://www.acmicpc.net/problem/13164) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/208 |

| 21์ฐจ์‹œ | 2024.06.07 | ๊ทธ๋ฆฌ๋”” | [ํ–‰๋ณต ์œ ์น˜์›](https://www.acmicpc.net/problem/13164) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/208 |
| 24์ฐจ์‹œ | 2024.08.12 | BFS | [๋งฅ์ฃผ ๋งˆ์‹œ๋ฉด์„œ ๊ฑธ์–ด๊ฐ€๊ธฐ](https://www.acmicpc.net/problem/9205) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/229 |

---

0 comments on commit bd62d9a

Please sign in to comment.