-
Notifications
You must be signed in to change notification settings - Fork 2
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
12-H0ngJu #180
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ΄ λ¬Έμ λ¬Έμ μ€λͺ μ΄ λ무 λΆμΉμ ν΄μ,,
λ¬Έμ μ΄ν΄νλλ° λ무 μ€λκ±Έλ Έμ΄μ. (μ¬μ§μ΄ κ·Έκ²λ κ²μν λ³΄κ³ μ΄ν΄ν¨..)
첨μ... κ·Έλ₯ λͺ¨λ μΉκ΅¬λ€μ΄ μ΄μ΄μ ΈμμΌλ©΄ λλ ? ν΄μ μ λμ¨ νμΈλλ‘ μ κ·Όνλλ°,
λ¬Έμ ν΅μ¬μ΄ κ·Έλ₯ 5λͺ μ μΉκ΅¬ μ΄μμ΄ μΌλ ¬λ‘ λμ΄λ μ μμΌλ©΄ λλ κ±°λλΌκ³ μ....
κ·Έλμ λ°λ‘ λ°±νΈλνΉμΌλ‘ μν..
ν΄...
import sys
from collections import defaultdict
def input(): return sys.stdin.readline().rstrip()
N, M = map(int, input().split())
graph = defaultdict(list)
def dfs(graph, now, depth, visited):
if depth >= 5: return True
for child in graph[now]:
if child in visited: continue
visited.add(child)
result = dfs(graph, child, depth+1, visited)
visited.discard(child)
if result: return True
return False
for _ in range(M):
first, second = map(int, input().split())
graph[first].append(second)
graph[second].append(first)
for idx in range(N):
result = dfs(graph, idx, 1, {idx,})
if result:
print(1)
break
else: print(0)
λ¬Έμ κ°.... κΉλνμ§ λͺ»νλ€.... μ€λͺ μ΄ λ νμνλ€...
κ·Όλ° μ λ°μ μΌλ‘ νμ£Όλ μ½λλ μ μ½λλ λ‘μ§μ κ°λ€μ....!
μμ£Ό λ€μ΄μ€~~~~~~~~~
|
||
for x in friends[friend]: | ||
if x not in stack: | ||
result = fr_check(x, stack.copy()) # 볡μ¬ν΄μΌ λ³λμ stackμ΄ λ§λ€μ΄μ Έμ μ λ¬ κ°λ₯ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μΉ΄νΌνλ κ²λ λ‘μ§μ κ°κΈ΄νλ°,
μκ° λ³΅μ‘λκ° μ§±μ§± λ§μ΄ λ€μμμ...!
(λ§μ½ λ°μ΄ν°κ° 10λ§κ°λ©΄ 10λ§ μκ°λ³΅μ‘λλκΉμ...! )
λ°±νΈλνΉ μ΄λΌλ κ²μ νλ² μ°Ύμ보μκ² μ΄μ ?!
νμ₯¬λ₯΄ ν μ μλ€ ν μ μλ°~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ κ° νΌ μ½λλ μ¬μ©... (λλ¦ κΉλνκ² μ μ§ κ² κ°λ€μ :))
νκ·λμ΄ μ μ΄μ£Όμ λλ‘, stack λ΄ μμλ₯Ό copyνλ 건 μκ°λ³΅μ‘λ μμΌλ‘ μ’μ§ μμ΅λλ€. λ°±νΈλνΉμ΄λ κ°λ
μ μ μ©νλ©΄ μ½λλ κ°κ²°ν΄μ§κ³ μ²λ¦¬λ μ½κ² ν μ μμΌλ©°, κ°λ
μμ²΄κ° μ€μνκΈ°λ ν©λλ€. κΌ ν λ² νμΈν΄λ³΄μΈμ!
input = open(0).readline
N, M = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(M):
a, b = map(int, input().split())
graph[a].append(b)
graph[b].append(a)
visited = [False] * N
def dfs(src: int, depth: int = 0) -> bool:
if depth == 4:
return True
visited[src] = True
for dst in graph[src]:
if visited[dst]:
continue
if dfs(dst, depth + 1):
return True
visited[src] = False
return False
def solution() -> bool:
for node in range(N):
if visited[node]:
continue
if dfs(node):
return True
return False
print('1' if solution() else '0')
π λ¬Έμ λ§ν¬
ABCDE
βοΈ μμλ μκ°
κ±°μ 2μκ°
β¨ μλ μ½λ
π μλ‘κ² μκ²λ λ΄μ©