Skip to content

Commit 10208ff

Browse files
authored
Merge pull request #598 from gmlrude/main
[박희경] 85차 라이브 코테 제출
2 parents 1e08fc9 + bc9abff commit 10208ff

3 files changed

Lines changed: 91 additions & 0 deletions

File tree

live8/test85/문제1/박희경.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import sys
2+
3+
input = sys.stdin.readline
4+
5+
6+
t = int(input())
7+
for _ in range(t):
8+
n = int(input())
9+
x = list(map(int, input().split()))
10+
11+
dic_x = set(x)
12+
x.sort() # -4, -1, 0, 2, 4
13+
14+
cnt = 0
15+
16+
for i in range(n): # ??..?
17+
for j in range(i + 1, n):
18+
dist = x[j] - x[i] # 두 점 사이 거리 (x[j]: 중간점)
19+
if x[j] + dist in dic_x:
20+
cnt += 1
21+
22+
print(cnt)
23+
"""
24+
2
25+
5
26+
2 0 -4 -1 4
27+
5
28+
1 3 2 5 4
29+
"""

live8/test85/문제2/박희경.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import sys
2+
from collections import *
3+
4+
input = sys.stdin.readline
5+
6+
dx = [-1, 1, 0, 0]
7+
dy = [0, 0, -1, 1]
8+
9+
10+
def bfs(x, y):
11+
q = deque([(x, y)])
12+
while q:
13+
x, y = q.popleft()
14+
for i in range(4):
15+
nx, ny = x + dx[i], y + dy[i]
16+
if 0 <= nx < h and 0 <= ny < w and grid[nx][ny] == '#':
17+
grid[nx][ny] = '.'
18+
q.append((nx, ny))
19+
return True
20+
21+
22+
t = int(input())
23+
for _ in range(t):
24+
h, w = map(int, input().split())
25+
grid = []
26+
for _ in range(h):
27+
grid.append(list(map(str, input().rstrip())))
28+
29+
cnt = 0
30+
for i in range(h):
31+
for j in range(w):
32+
if grid[i][j] == '#':
33+
if bfs(i, j):
34+
cnt += 1
35+
print(cnt)
36+
37+
38+
"""
39+
2
40+
4 4
41+
#.#.
42+
.#.#
43+
#.##
44+
.#.#
45+
3 5
46+
###.#
47+
..#..
48+
#.###
49+
"""

live8/test85/문제3/박희경.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
def solution(clothes):
2+
clothes_dict = {}
3+
for name, kind in clothes:
4+
if kind in clothes_dict.keys():
5+
clothes_dict[kind].append(name)
6+
else:
7+
clothes_dict[kind] = [name]
8+
9+
# (n + 1) * (m + 1) - 1
10+
answer = 1
11+
for key, values in clothes_dict.items():
12+
answer *= len(values) + 1
13+
return answer - 1

0 commit comments

Comments
 (0)