Skip to content

Commit

Permalink
Merge branch 'main' into 26-alstjr7437
Browse files Browse the repository at this point in the history
  • Loading branch information
alstjr7437 authored May 22, 2024
2 parents 223409d + 8da6d44 commit 08661c2
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 6 deletions.
1 change: 1 addition & 0 deletions alstjr7437/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@
| 22์ฐจ์‹œ | 2024.04.13 | BFS | <a href="https://www.acmicpc.net/problem/11724">์—ฐ๊ฒฐ ์š”์†Œ์˜ ๊ฐœ์ˆ˜</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/78 |
| 23์ฐจ์‹œ | 2024.05.01 | ํ | <a href="https://school.programmers.co.kr/learn/courses/30/lessons/42587">ํ”„๋กœ์„ธ์Šค</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/79 |
| 24์ฐจ์‹œ | 2024.05.14 | BFS | <a href="https://www.acmicpc.net/problem/7576">ํ† ๋งˆํ† </a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/187 |
| 25์ฐจ์‹œ | 2024.05.18 | ๋ฑ | <a href="https://www.acmicpc.net/problem/5430">AC</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/190 |
| 26์ฐจ์‹œ | 2024.05.22 | ์ •๋ ฌ | <a href="https://school.programmers.co.kr/learn/courses/30/lessons/42747">H-Index</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/196 |
41 changes: 41 additions & 0 deletions alstjr7437/๋ฑ/AC.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from collections import deque
import sys
input = sys.stdin.readline

t = int(input())

for _ in range(t):
temp_reverse = False
error = 0

p = input()
n = int(input())
x = deque(input().strip()[1:-1].split(','))

if n == 0 :
x = deque()

for i in p:
if i == 'R':
if temp_reverse :
temp_reverse = False
else :
temp_reverse = True

if i == "D":
if len(x) == 0:
error = 1
break
else :
if temp_reverse :
x.pop()
else :
x.popleft()

if temp_reverse :
x.reverse()

if error == 0 :
print(f"[{','.join(str(i) for i in x)}]")
else :
print("error")
17 changes: 11 additions & 6 deletions tgyuuAn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,19 @@
| 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
| 55์ฐจ์‹œ | 2023.05.18 | ์œ ๋‹ˆ์˜จ ํŒŒ์ธ๋“œ | <a href="https://www.acmicpc.net/problem/4195">์นœ๊ตฌ ๋„คํŠธ์›Œํฌ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/189
---
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))
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import sys
from collections import defaultdict

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

def find_parent(element, graph):
if graph[element] == element: return element

parent = graph[element]
graph[element] = find_parent(parent, graph)
return graph[element]

def union(first, second, graph, count):
x = find_parent(first, graph)
y = find_parent(second, graph)

if x == y: return

x, y = min(x, y), max(x, y)
graph[y] = x
count[x] += count[y]
count[y] = 0
return

T = int(input())

for _ in range(T):
F = int(input())
index = 1
parent = defaultdict(str)
count = defaultdict(lambda : 1)

for _ in range(F):
first, second = input().split()
if parent[first] == "": parent[first] = first
if parent[second] == "": parent[second] = second
if parent[first] != parent[second]: union(first, second, parent, count)

print(count[find_parent(first, parent)])

0 comments on commit 08661c2

Please sign in to comment.