Skip to content

Commit

Permalink
2024-04-09
Browse files Browse the repository at this point in the history
  • Loading branch information
H0ngJu committed Apr 9, 2024
1 parent 91b36eb commit 4f2026e
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 9 deletions.
43 changes: 43 additions & 0 deletions H0ngJu/DFS/ABCDE.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import sys

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

# ์žฌ๊ท€ํ•จ์ˆ˜ fr_check
def fr_check(friend, stack):
stack.append(friend) # ํ˜„์žฌ ์นœ๊ตฌ๋ฅผ ์Šคํƒ์— ์ถ”๊ฐ€
print(stack)

if len(stack) == 5: # ์นœ๊ตฌ 5๋ช… ๋˜๋ฉด
return stack

for x in friends[friend]:
if x not in stack:
result = fr_check(x, stack.copy()) # ๋ณต์‚ฌํ•ด์•ผ ๋ณ„๋„์˜ stack์ด ๋งŒ๋“ค์–ด์ ธ์„œ ์ „๋‹ฌ ๊ฐ€๋Šฅ
if result is not None:
return result

return None # stack์ด 5๊ฐ€ ๋˜์ง€ ์•Š์€ ๊ฒฝ์šฐ


N, M = map(int, input().split())
friends = [[] for _ in range(N)] #freind[i]์—๋Š” i์˜ ์นœ๊ตฌ ๋‹ด๊ธฐ
fcheck = 0
stack = []


for _ in range(M):
f0, f1 = map(int, input().split())
friends[f0].append(f1)
friends[f1].append(f0)


for idx in range(N):
stack = []
result = fr_check(idx, stack) #idx๋ถ€ํ„ฐ ์ฒดํฌ ์‹œ์ž‘
if result != None and len(result) == 5:
fcheck = 1
print("1")
break

if fcheck == 0:
print(0)
19 changes: 10 additions & 9 deletions H0ngJu/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
## โœ๏ธ ๊ธฐ๋ก

| ์ฐจ์‹œ | ๋‚ ์งœ | ๋ฌธ์ œ์œ ํ˜• | ๋งํฌ | ํ’€์ด |
| :---: | :--------: | :------: | :-------------------------------------------------------------------------: | :-------------------------------------------------: |
| 1์ฐจ์‹œ | 2024.03.05 | ํ | [ํ”„๋กœ์„ธ์Šค](https://school.programmers.co.kr/learn/courses/30/lessons/42587) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/151 |
| 2์ฐจ์‹œ | 2024.03.07 | ํ | [๋‹ค๋ฆฌ๋ฅผ ์ง€๋‚˜๋Š” ํŠธ๋Ÿญ](https://school.programmers.co.kr/learn/courses/30/lessons/42583) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/153 |
| 3์ฐจ์‹œ | 2024.03.10 | ํž™ | [N๋ฒˆ์งธ ํฐ ์ˆ˜](https://www.acmicpc.net/problem/2075) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/156 |
| 4์ฐจ์‹œ | 2024.03.13 | ํž™ | [๋ฌธ์ œ์ง‘](https://www.acmicpc.net/problem/1766) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/158 |
| 5์ฐจ์‹œ | 2024.03.16 | ๊ตฌํ˜„ | [์š”์„ธํ‘ธ์Šค ๋ฌธ์ œ](https://www.acmicpc.net/problem/1158) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/161 |
| 6์ฐจ์‹œ | 2024.03.19 | ์Šคํƒ | [์˜คํฐ์ˆ˜](https://www.acmicpc.net/problem/17298) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/164 |
| 7์ฐจ์‹œ | 2024.03.22 | DP | [1,2,3 ๋”ํ•˜๊ธฐ](https://www.acmicpc.net/problem/9095) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/166 |
| ์ฐจ์‹œ | ๋‚ ์งœ | ๋ฌธ์ œ์œ ํ˜• | ๋งํฌ | ํ’€์ด |
| :----: | :--------: | :------: | :-----------------------------------------------------------------------------------: | :-------------------------------------------------: |
| 1์ฐจ์‹œ | 2024.03.05 | ํ | [ํ”„๋กœ์„ธ์Šค](https://school.programmers.co.kr/learn/courses/30/lessons/42587) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/151 |
| 2์ฐจ์‹œ | 2024.03.07 | ํ | [๋‹ค๋ฆฌ๋ฅผ ์ง€๋‚˜๋Š” ํŠธ๋Ÿญ](https://school.programmers.co.kr/learn/courses/30/lessons/42583) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/153 |
| 3์ฐจ์‹œ | 2024.03.10 | ํž™ | [N๋ฒˆ์งธ ํฐ ์ˆ˜](https://www.acmicpc.net/problem/2075) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/156 |
| 4์ฐจ์‹œ | 2024.03.13 | ํž™ | [๋ฌธ์ œ์ง‘](https://www.acmicpc.net/problem/1766) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/158 |
| 5์ฐจ์‹œ | 2024.03.16 | ๊ตฌํ˜„ | [์š”์„ธํ‘ธ์Šค ๋ฌธ์ œ](https://www.acmicpc.net/problem/1158) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/161 |
| 6์ฐจ์‹œ | 2024.03.19 | ์Šคํƒ | [์˜คํฐ์ˆ˜](https://www.acmicpc.net/problem/17298) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/164 |
| 7์ฐจ์‹œ | 2024.03.22 | DP | [1,2,3 ๋”ํ•˜๊ธฐ](https://www.acmicpc.net/problem/9095) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/166 |
| 12์ฐจ์‹œ | 2024.04.09 | DFS | [ABCDE](https://www.acmicpc.net/problem/13023) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/180 |

---

0 comments on commit 4f2026e

Please sign in to comment.