Skip to content

Commit

Permalink
230411
Browse files Browse the repository at this point in the history
  • Loading branch information
gkrry2723 committed Apr 11, 2023
1 parent c884f2d commit 83d842b
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 1 deletion.
Empty file.
2 changes: 1 addition & 1 deletion KHJ/두잇/044_칵테일_1033.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

def gcd(a,b):
if a<b:
a, b = b, A
a, b = b, a
while b != 0:
a, b = b, a % b
return a
Expand Down
37 changes: 37 additions & 0 deletions KHJ/두잇/046_특정거리의도시찾기_18352.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import sys
from collections import deque
input = sys.stdin.readline


N, M, K, X = map(int, input().split())
A = [[] for _ in range(N+1)]
queue = deque()
visited = [False for _ in range(N+1)]
dist = [0]*(N+1)

for _ in range(M):
a, b = map(int, input().split())
A[a].append(b)

queue.append(X)
answer = []

while queue:
now = queue.popleft()
#print(now)
if not visited[now]:
visited[now] = True
for x in A[now]:
if not visited[x] and dist[x] == 0:
dist[x] = dist[now] + 1
if dist[x] == K:
answer.append(x)
queue.append(x)
#print(queue, dist, visited)

if answer:
answer.sort()
for x in answer:
print(x)
else:
print(-1)
35 changes: 35 additions & 0 deletions KHJ/두잇/047_효율적인해킹_1325.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import sys
from collections import deque
input = sys.stdin.readline
N, M = map(int, input().split())
graph = [[] for _ in range(N+1)]
answer = [0] * (N+1)

def BFS(v):
queue = deque()
queue.append(v)
visited[v] = True
while queue:
now = queue.popleft()
for i in graph[now]:
if not visited[i]:
visited[i] = True
answer[i] += 1
queue.append(i)


for _ in range(M):
a, b = map(int, input().split())
graph[a].append(b)

for i in range(1,N+1):
visited = [False]*(N+1)
BFS(i)

maxVal = 0
for i in range(1, N+1):
maxVal = max(maxVal, answer[i])

for i in range(1, N+1):
if answer[i] == maxVal:
print(i, end=' ')

0 comments on commit 83d842b

Please sign in to comment.