Skip to content

Commit

Permalink
2024-05-09
Browse files Browse the repository at this point in the history
  • Loading branch information
H0ngJu committed May 9, 2024
1 parent c50ebb1 commit ae6f77a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
32 changes: 32 additions & 0 deletions H0ngJu/DFS/์น˜ํ‚จ ๋ฐฐ๋‹ฌ.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import sys
from itertools import combinations

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

N, M = map(int, input().split())
house = [[] for _ in range(N)]
chicken_house = []
chicken_dis = [[9999 for _ in range(N)] for _ in range(N)]
result = 99999

for i in range(N):
house[i].extend(map(int, input().split()))

for r in range(N):
for c in range(N):
if house[r][c] == 2:
chicken_house.append((r, c))

for chickens in combinations(chicken_house, M):
total = 0
for r in range(N):
for c in range(N):
if house[r][c] == 1:
tmp = 9999
for chicken in chickens:
tmp = min(tmp, abs(r - chicken[0]) + abs(c - chicken[1]))
total += tmp

result = min(result, total)

print(result)
1 change: 1 addition & 0 deletions H0ngJu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
| 10์ฐจ์‹œ | 2024.04.03 | BFS | [์ˆจ๋ฐ”๊ผญ์งˆ 4](https://www.acmicpc.net/problem/13913) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/177 |
| 11์ฐจ์‹œ | 2024.04.07 | ๊ตฌํ˜„ | [์‚ฌํƒ• ๊ฒŒ์ž„](https://www.acmicpc.net/problem/9095) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/178 |
| 12์ฐจ์‹œ | 2024.04.09 | DFS | [ABCDE](https://www.acmicpc.net/problem/13023) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/180 |
| 14์ฐจ์‹œ | 2024.05.09 | DFS | [์น˜ํ‚จ๋ฐฐ๋‹ฌ](https://www.acmicpc.net/problem/15686) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/183 |

---

0 comments on commit ae6f77a

Please sign in to comment.