Notice
Recent Posts
Recent Comments
Link
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- Entity
- ์๋ฒ ํฐ์ง๋ ๋์ปค ์ฌ์คํ
- docker-compose kafka
- ์คํํ๋ ๋ฏธ์ค
- aws saa ํฉ๊ฒฉ
- JPA
- AWS Certified Solutions Architect - Associate
- prod docker-compose
- redis ํ ์คํธ์ฝ๋
- ํ๋ก๊ทธ๋๋จธ์ค
- private subnet ec2 ๋ก์ปฌ ์ ์
- docker ps -a
- jvm ๋ฐ๋ฐ๋ฅ๊น์ง ํํค์น๊ธฐ
- docker
- ํ์ดํผ๋ฐ์ด์
- docker compose
- nGrinder
- ์๋ฐ
- ํ๋ก๊ทธ๋๋จธ์ค ํฉ์นํ์์๊ธ
- ๋ค์ค ์ปจํ ์ด๋
- s3 ์ด๋ฏธ์ง ์ ์ฅ
- Kafka
- s3 ์ด๋ฏธ์ง ๋ค์ด๋ก๋
- redis ์กฐํ
- ์ ํจ์ค ๋น๋ ์ค๋ฅ
- ์ ํจ์ค ์ค์ผ์ค๋ฌ
- aws ์ฟ ํฐ
- Codedeploy ์ค๋ฅ
- s3 log ์ ์ฅ
- ํ๋ก๊ทธ๋๋จธ์ค ์ปฌ๋ฌ๋ง๋ถ
Archives
- Today
- Total
๐๐ข๐๐ โ๐๐๐ ๐๐๐ก๐๐ ๐๐๐๐โง
[Python] ๋ฐฑ์ค 1743 & 1303 ๋ณธ๋ฌธ
๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ด๐ป/[๐๐ฒ๐ญ๐ก๐จ๐ง] ๐๐ฅ๐ ๐จ๐ซ๐ข๐ญ๐ก๐ฆ
[Python] ๋ฐฑ์ค 1743 & 1303
๐คRyusun๐ค 2023. 8. 27. 01:40# ๋ฐฑ์ค 1743
from collections import deque
import sys
n, m, k = map(int, sys.stdin.readline().split())
graph = [[0]* m for _ in range(n)]
for _ in range(k):
a, b = map(int,sys.stdin.readline().split())
graph[a-1][b-1] = 1
d_row = [0, -1, 0, 1]
d_col = [1, 0, -1, 0]
def bfs(result, i, j):
queue = deque()
queue.append([i, j])
cnt = 0
while queue:
x, y = queue.popleft()
for next in range(4):
nx = x+ d_row[next]
ny = y + d_col[next]
if nx < 0 or ny < 0 or nx > n-1 or ny > m-1:
continue
elif graph[nx][ny] == 1 :
queue.append([nx, ny])
graph[nx][ny] = 0
cnt += 1
if cnt == 0:
cnt = 1
return result.append(cnt)
result = []
for i in range(n):
for j in range(m):
if graph[i][j] == 1:
bfs(result, i, j)
print(max(result))
#๋ฐฑ์ค 1303
import sys
from collections import deque
input = sys.stdin.readline
queue = deque()
m, n = map(int, input().split())
graph= [list(map(str, input().rstrip())) for _ in range(n)]
visited = [[False]* m for _ in range(n)]
d_row = [0, -1, 0, 1]
d_col = [1, 0, -1, 0]
def bfs(i, j, us_cnt, them_cnt):
queue.append([i, j])
visited[i][j] = True
graph[i][j] = graph[i][j].lower() #๋ฐฉ๋ฌธํ๋ฉด ํด๋น ์ํ๋ฒณ์ ์๋ฌธ์๋ก ๋ฐ๊พผ๋ค.
while queue:
x, y = queue.popleft()
for d in range(4):
dx = x + d_row[d]
dy = y + d_col[d]
if dx < 0 or dy < 0 or dx > n-1 or dy > m-1:
continue
if graph[x][y] == 'w' and graph[dx][dy] == 'W' and not visited[dx][dy]:
queue.append([dx, dy])
visited[dx][dy] = True
graph[dx][dy] = 'w'
us_cnt += 1
elif graph[x][y] == 'b' and graph[dx][dy] == 'B' and not visited[dx][dy]:
queue.append([dx, dy])
visited[dx][dy] = True
graph[dx][dy] = 'b'
them_cnt += 1
return us_cnt, them_cnt
us_list = []
them_list = []
for i in range(n):
for j in range(m):
if graph[i][j] == 'W':
result = bfs(i, j, 1, 0)[0]
us_list.append(result)
elif graph[i][j] == 'B':
result = bfs(i, j, 0, 1)[1]
them_list.append(result)
us_list = sum([x ** 2 for x in us_list])
them_list = sum([y ** 2 for y in them_list])
print(us_list, them_list)
'๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ด๐ป > [๐๐ฒ๐ญ๐ก๐จ๐ง] ๐๐ฅ๐ ๐จ๐ซ๐ข๐ญ๐ก๐ฆ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Python] ๋ฐฑ์ค 16165 & ๋ฐฑ์ค 2908 (0) | 2023.08.28 |
---|---|
[Python] ๋ฐฑ์ค 1916 & ๋ฐฑ์ค 2309 (0) | 2023.08.27 |
[Python] ๋ฐฑ์ค 5014 & ํ๋ก๊ทธ๋๋จธ์ค ์คํ์ฑํ ๋ฐฉ (0) | 2023.07.31 |
[Python] ๋ฐฑ์ค 1759 & ๋ฐฑ์ค 1987 (0) | 2023.07.26 |
[Python] ๋ฐฑ์ค 1325 & ๋ฐฑ์ค 1668 (0) | 2023.07.25 |