Skip to content

Commit

Permalink
Merge branch 'main' into 31-H0ngJu
Browse files Browse the repository at this point in the history
  • Loading branch information
H0ngJu authored Oct 10, 2024
2 parents 7122c4e + 7d102be commit a2d6396
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 3 deletions.
6 changes: 3 additions & 3 deletions H0ngJu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
| 26์ฐจ์‹œ | 2024.08.24 | ๊ทธ๋ฆฌ๋”” | [์‹ ์ž…์‚ฌ์›](https://www.acmicpc.net/problem/1946) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/237 |
| 27์ฐจ์‹œ | 2024.08.27 | DFS | [ํŠธ๋ฆฌ์˜ ์ง€๋ฆ„](https://www.acmicpc.net/problem/1967) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/240 |
| 28์ฐจ์‹œ | 2024.09.04 | ๋ฒจ๋งŒํฌ๋“œ | [ํƒ€์ž„๋จธ์‹ ](https://www.acmicpc.net/problem/11657) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/244 |
| 29์ฐจ์‹œ | 2024.09.06 | ๊ตฌํ˜„ | [ํ†ฑ๋‹ˆ๋ฐ”ํ€ด](https://www.acmicpc.net/problem/14891) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/245 |

## | 31์ฐจ์‹œ | 2024.10.05 | ์ •๋ ฌ | [์„  ๊ธ‹๊ธฐ](https://www.acmicpc.net/problem/2170) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/249 |
| 29์ฐจ์‹œ | 2024.09.06 | ๊ตฌํ˜„ |[ํ†ฑ๋‹ˆ๋ฐ”ํ€ด](https://www.acmicpc.net/problem/14891) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/245 |
| 30์ฐจ์‹œ | 2024.09.27 | ์ˆ˜ํ•™ | [Fly me to the Alpha Centauri](https://www.acmicpc.net/problem/1011) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/248 |
| 31์ฐจ์‹œ | 2024.10.05 | ์ •๋ ฌ | [์„  ๊ธ‹๊ธฐ](https://www.acmicpc.net/problem/2170) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/249 |
21 changes: 21 additions & 0 deletions H0ngJu/์ˆ˜ํ•™/Fly me to the Alpha Centauri.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import sys

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

T = int(input())

for _ in range(T):
x, y = map(int, input().split())
distance = y - x
cnt = 0

for _ in range(distance+1):
if distance <= cnt**2:
break
else:
cnt += 1

if distance <= (cnt-1)*cnt:
print((cnt-1)*2)
else:
print(cnt*2-1)
1 change: 1 addition & 0 deletions tgyuuAn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,5 @@
| 74์ฐจ์‹œ | 2024.08.30 | BFS | <a href="https://www.acmicpc.net/problem/11967">๋ถˆ ์ผœ๊ธฐ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/242
| 75์ฐจ์‹œ | 2024.09.02 | DP | <a href="https://school.programmers.co.kr/learn/courses/30/lessons/258705">์‚ฐ ๋ชจ์–‘ ํƒ€์ผ๋ง</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/243
| 76์ฐจ์‹œ | 2024.09.06 | DFS + ํŠธ๋ฆฌ | <a href="https://school.programmers.co.kr/learn/courses/30/lessons/150367">ํ‘œํ˜„ ๊ฐ€๋Šฅํ•œ ์ด์ง„ํŠธ๋ฆฌ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/246
| 77์ฐจ์‹œ | 2024.09.27 | ๊ตฌํ˜„ | <a href="https://school.programmers.co.kr/learn/courses/30/lessons/150366">ํ‘œ ๋ณ‘ํ•ฉ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/247
---
101 changes: 101 additions & 0 deletions tgyuuAn/๊ตฌํ˜„/ํ‘œ ๋ณ‘ํ•ฉ.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
from collections import defaultdict

def solution(commands):
table = [[None for _ in range(52)] for _ in range(52)]
linked_dict = defaultdict(set)
value_dict = defaultdict(set)
answer = []

for command in commands:
splt = command.split()
length = len(splt)
query = splt[0]

if query == "UPDATE":
if(length == 3):
value1, value2 = splt[1], splt[2]

temp = set()
for (r, c) in value_dict[value1]:
table[r][c] = value2
temp.add((r,c))

value_dict[value1] = set()
value_dict[value2].update(temp)

elif(length == 4):
r, c, value1 = int(splt[1]), int(splt[2]), splt[3]

origin = table[r][c]
if len(linked_dict[(r,c)]) == 0:
table[r][c] = value1
value_dict[value1].add((r,c))
if origin is not None: value_dict[origin].discard((r,c))

else:
for (l_r, l_c) in linked_dict[(r,c)]:
if origin is not None: value_dict[origin].discard((l_r, l_c))
table[l_r][l_c] = value1

value_dict[value1].update(linked_dict[(r,c)])

elif query == "MERGE":
r1, c1, r2, c2 = int(splt[1]), int(splt[2]), int(splt[3]), int(splt[4])

if((r1, c1) == (r2, c2)): continue
value1 = table[r1][c1]
value2 = table[r2][c2]
merge_value = None
if value1 is not None and value2 is not None:
merge_value = value1

elif value1 is not None:
merge_value = value1

elif value2 is not None:
merge_value = value2

all_element = {(r1, c1), (r2, c2)}

value1_element = {(r1, c1)} | linked_dict[(r1, c1)]
value2_element = {(r2, c2)} | linked_dict[(r2, c2)]
all_element = value1_element | value2_element

if value1 is None and value2 is not None:
for (el_r, el_c) in value1_element:
table[el_r][el_c] = merge_value

value_dict[value2].add((el_r, el_c))

if not(value1 is None and value2 is None):
for (el_r, el_c) in value2_element:
table[el_r][el_c] = merge_value

if value1 is not None and value2 is not None:
value_dict[value2].discard((el_r, el_c))
value_dict[value1].add((el_r, el_c))

elif value1 is not None:
value_dict[value2].discard((el_r, el_c))
value_dict[value1].add((el_r, el_c))

for (l_r, l_c) in all_element:
linked_dict[(l_r, l_c)] = all_element

elif query =="UNMERGE":
r, c = int(splt[1]), int(splt[2])
value1 = table[r][c]
value_dict[value1] -= linked_dict[(r, c)]

for (now_r, now_c) in linked_dict[(r, c)]:
linked_dict[(now_r, now_c)] = set()
table[now_r][now_c] = None

table[r][c] = value1
value_dict[value1].add((r,c))

elif query =="PRINT":
r, c = int(splt[1]), int(splt[2])
answer.append(table[r][c] if table[r][c] is not None else "EMPTY")

return answer

0 comments on commit a2d6396

Please sign in to comment.