Skip to content
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

54-tgyuuAn #185

Merged
merged 1 commit into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions tgyuuAn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@
| 41μ°¨μ‹œ | 2024.03.04 | DP | <a href="https://www.acmicpc.net/problem/2240">μžλ‘λ‚˜λ¬΄</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/148
| 42μ°¨μ‹œ | 2024.03.07 | DFS | <a href="https://www.acmicpc.net/problem/2239">μŠ€λ„μΏ </a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/152
| 43μ°¨μ‹œ | 2024.03.10 | 이뢄 탐색 | <a href="https://school.programmers.co.kr/learn/courses/30/lessons/64062">징검닀리 κ±΄λ„ˆκΈ°</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/157
| 44μ°¨μ‹œ | 2023.03.13 | 트라이 | <a href="https://www.acmicpc.net/problem/14725">개미꡴</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/159
| 45μ°¨μ‹œ | 2023.03.16 | 트라이 | <a href="https://www.acmicpc.net/problem/31413">트라이</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/162
| 46μ°¨μ‹œ | 2023.03.20 | 트라이 | <a href="https://www.acmicpc.net/problem/27652">AB</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/165
| 47μ°¨μ‹œ | 2023.03.22 | μˆ˜ν•™, 뢄할정볡 | <a href="https://www.acmicpc.net/problem/15824">λ„ˆ λ΄„μ—λŠ” 캑사이신이 λ§›μžˆλ‹¨λ‹€</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/167
| 48μ°¨μ‹œ | 2023.03.25 | 벨만 ν¬λ“œ | <a href="https://www.acmicpc.net/problem/1738">골λͺ©κΈΈ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/171
| 49μ°¨μ‹œ | 2023.03.29 | DP | <a href="https://www.acmicpc.net/problem/10217">KCM Travel</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/174
| 44μ°¨μ‹œ | 2024.03.13 | 트라이 | <a href="https://www.acmicpc.net/problem/14725">개미꡴</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/159
| 45μ°¨μ‹œ | 2024.03.16 | 트라이 | <a href="https://www.acmicpc.net/problem/31413">트라이</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/162
| 46μ°¨μ‹œ | 2024.03.20 | 트라이 | <a href="https://www.acmicpc.net/problem/27652">AB</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/165
| 47μ°¨μ‹œ | 2024.03.22 | μˆ˜ν•™, 뢄할정볡 | <a href="https://www.acmicpc.net/problem/15824">λ„ˆ λ΄„μ—λŠ” 캑사이신이 λ§›μžˆλ‹¨λ‹€</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/167
| 48μ°¨μ‹œ | 2024.03.25 | 벨만 ν¬λ“œ | <a href="https://www.acmicpc.net/problem/1738">골λͺ©κΈΈ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/171
| 49μ°¨μ‹œ | 2024.03.29 | DP | <a href="https://www.acmicpc.net/problem/10217">KCM Travel</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/174
| 50μ°¨μ‹œ | 2024.04.01 | BFS | <a href="https://www.acmicpc.net/problem/9328">μ—΄μ‡ </a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/175
| 51μ°¨μ‹œ | 2023.04.07 | BFS | <a href="https://www.acmicpc.net/problem/5213">과외맨</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/179
| 52μ°¨μ‹œ | 2023.05.06 | μœ„μƒμ •λ ¬ | <a href="https://www.acmicpc.net/problem/1516">κ²Œμž„ 개발</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/182
| 53μ°¨μ‹œ | 2023.05.09 | λ°±νŠΈλž˜ν‚Ή | <a href="https://www.acmicpc.net/problem/12100">2048 (Easy)</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/184
| 51μ°¨μ‹œ | 2024.04.07 | BFS | <a href="https://www.acmicpc.net/problem/5213">과외맨</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/179
| 52μ°¨μ‹œ | 2024.05.06 | μœ„μƒμ •λ ¬ | <a href="https://www.acmicpc.net/problem/1516">κ²Œμž„ 개발</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/182
| 53μ°¨μ‹œ | 2024.05.09 | λ°±νŠΈλž˜ν‚Ή | <a href="https://www.acmicpc.net/problem/12100">2048 (Easy)</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/184
| 54μ°¨μ‹œ | 2024.05.14 | λ‹€μ΅μŠ€νŠΈλΌ | <a href="https://www.acmicpc.net/problem/9370">미확인 도착지</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/185
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
from collections import defaultdict
from heapq import *
import sys

INF = 50_000_001

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

T = int(input())

for _ in range(T):
cnt_node, cnt_edge, cnt_dedication = map(int, input().split())
start_node, g, h = map(int, input().split())

graph = defaultdict(lambda : defaultdict(int))
for _ in range(cnt_edge):
start, destination, cost = map(int,input().split())
graph[start][destination] = cost
graph[destination][start] = cost

node_dedications = set()
for _ in range(cnt_dedication):
node_dedications.add(int(input()))

table = [INF for _ in range(cnt_node+1)]
table[start_node] = 0

visited = set()
heap = []
heappush(heap, [0, start_node, 1])
flag = [1 for _ in range(cnt_node+1)]

while heap:
now_cost, now_node, now_flag = heappop(heap)

if now_node in visited: continue
visited.add(now_node)

if flag[now_node] == 1 and now_flag == 0: flag[now_node] = 0

for next_node in graph[now_node]:
cost = graph[now_node][next_node]

if (now_cost + cost) > table[next_node]: continue

table[next_node] = now_cost + cost

new_flag = now_flag
# λ§Œμ•½, μ§€κΈˆ μ›€μ§μ΄λ €λŠ” λ„λ‘œκ°€ λƒ„μƒˆκ°€ λ‚˜λŠ” λ„λ‘œμ˜€μ„ 경우 flagλ₯Ό 0둜 λ°”κΏˆ
if (now_node, next_node) in {(g, h), (h, g)}: new_flag = 0

heappush(heap, [now_cost + cost, next_node, new_flag])

answer = []
for dedication in node_dedications:
if flag[dedication] == 0: answer.append(dedication)

print(*sorted(answer))
Loading