Skip to content

Commit 8ba8921

Browse files
authored
Merge pull request #642 from Yujin-Baek/main
[백유진] 95차 라이브 코테 제출
2 parents b625098 + 78c2900 commit 8ba8921

3 files changed

Lines changed: 59 additions & 0 deletions

File tree

live9/test95/문제1/백유진.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from itertools import permutations
2+
3+
def solution(k, dungeons):
4+
answer = float("-inf")
5+
6+
for dungeon in permutations(dungeons, len(dungeons)):
7+
temp_k = k
8+
max = 0
9+
for min_p, minus_p in dungeon:
10+
if temp_k >= min_p:
11+
temp_k -= minus_p
12+
max += 1
13+
if max > answer:
14+
answer = max
15+
return answer

live9/test95/문제2/백유진.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
def dfs(node, graph, visited):
2+
visited[node] = True
3+
size = 1
4+
5+
for neighbor in graph[node]:
6+
if not visited[neighbor]:
7+
size += dfs(neighbor, graph, visited)
8+
9+
return size
10+
11+
def solution(n, wires):
12+
answer = float('inf')
13+
14+
for i in range(len(wires)):
15+
count = 0
16+
w_copy = wires[:]
17+
w_copy.pop(i)
18+
print(w_copy)
19+
graph = [[] for _ in range(n+1)]
20+
21+
for wire in w_copy:
22+
graph[wire[0]].append(wire[1])
23+
graph[wire[1]].append(wire[0])
24+
25+
visited = [False] * (n + 1)
26+
size_one = dfs(w_copy[0][0], graph, visited)
27+
size_two = n - size_one
28+
29+
answer = min(answer, abs(size_one - size_two))
30+
31+
print(count)
32+
return answer

live9/test95/문제3/백유진.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
def solution(brown, yellow):
2+
answer = []
3+
4+
total = brown + yellow
5+
6+
for h in range(1, total+1):
7+
if total%h == 0:
8+
w = total//h
9+
if (w-2)*(h-2) == yellow:
10+
return [w, h]
11+
12+
return answer

0 commit comments

Comments
 (0)