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
- ํ์ดํผ๋ฐ์ด์
- ๋ค์ค ์ปจํ ์ด๋
- private subnet ec2 ๋ก์ปฌ ์ ์
- aws saa ํฉ๊ฒฉ
- ํ๋ก๊ทธ๋๋จธ์ค
- AWS Certified Solutions Architect - Associate
- ์๋ฐ
- s3 ์ด๋ฏธ์ง ์ ์ฅ
- ์ ํจ์ค ์ค์ผ์ค๋ฌ
- ์๋ฒ ํฐ์ง๋ ๋์ปค ์ฌ์คํ
- Entity
- prod docker-compose
- ์ ํจ์ค ๋น๋ ์ค๋ฅ
- docker compose
- redis ํ ์คํธ์ฝ๋
- Kafka
- ํ๋ก๊ทธ๋๋จธ์ค ํฉ์นํ์์๊ธ
- ํ๋ก๊ทธ๋๋จธ์ค ์ปฌ๋ฌ๋ง๋ถ
- Codedeploy ์ค๋ฅ
- JPA
- s3 ์ด๋ฏธ์ง ๋ค์ด๋ก๋
- s3 log ์ ์ฅ
- docker-compose kafka
- redis ์กฐํ
- jvm ๋ฐ๋ฐ๋ฅ๊น์ง ํํค์น๊ธฐ
- nGrinder
- docker
- docker ps -a
- ์คํํ๋ ๋ฏธ์ค
- aws ์ฟ ํฐ
Archives
- Today
- Total
๐๐ข๐๐ โ๐๐๐ ๐๐๐ก๐๐ ๐๐๐๐โง
[Python] ๋ฐฑ์ค 16956 ๋ณธ๋ฌธ
๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ด๐ป/[๐๐ฒ๐ญ๐ก๐จ๐ง] ๐๐ฅ๐ ๐จ๐ซ๐ข๐ญ๐ก๐ฆ
[Python] ๋ฐฑ์ค 16956
๐คRyusun๐ค 2023. 8. 29. 12:4116956๋ฒ - ํ์ด 1( bfs๋ก ํ์ด)
#๋ฐฑ์ค 16956 ํ์ด 1
import sys
from collections import deque
input = sys.stdin.readline
r, c = map(int, input().split())
graph = [list(map(str, input().rstrip())) for _ in range(r)]
visited = [[False] * c for _ in range(r)]
d_row = [0, -1, 0, 1]
d_col = [1, 0, -1, 0]
def bfs():
queue = deque()
flag = False
for i in range(r):
for j in range(c):
if graph[i][j] == 'W':
queue.append([i, j])
visited[i][j] = True
while queue:
x, y = queue.popleft()
for i in range(4):
nx = x + d_row[i]
ny = y + d_col[i]
if 0<= nx < r and 0<= ny < c:
if graph[x][y] == 'W' and graph[nx][ny] == 'S':
flag = True
if graph[x][y] == 'W' and not visited[nx][ny] and graph[nx][ny] == '.':
graph[nx][ny] = 'D'
visited[nx][ny] = True
if flag:
print(0)
return
else:
print(1)
for row in graph:
print(''.join(row))
return
bfs()
16956๋ฒ - ํ์ด2 (๋จ์ ๋ฐ๋ณต๋ฌธ)
# ๋ฐฑ์ค 16956 - ํ์ด 2
n, m = map(int, input().split())
graph = []
for i in range(n):
graph.append(list(input().rstrip()))
d_row = [0, -1, 0, +1]
d_col = [+1, 0, -1, 0]
flag = False
for i in range(n):
for j in range(m):
if graph[i][j] == 'W':
for x in range(4):
next_row = i + d_row[x]
next_col = j + d_col[x]
if next_row < 0 or next_col < 0 or next_row > n - 1 or next_col > m - 1:
continue
if graph[next_row][next_col] == 'S':
flag = True
break
if graph[next_row][next_col] != '.':
continue
graph[next_row][next_col] = 'D'
if flag:
print(0)
else:
print(1)
for i in graph: ## ์ด ๋ถ๋ถ ์ค์!!!
print(''.join(i))
'๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ด๐ป > [๐๐ฒ๐ญ๐ก๐จ๐ง] ๐๐ฅ๐ ๐จ๐ซ๐ข๐ญ๐ก๐ฆ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Python] ํ๋ก๊ทธ๋๋จธ์ค ๊ฑฐ๋ฆฌ๋๊ธฐ ํ์ธํ๊ธฐ & ํ๋ก๊ทธ๋๋จธ์ค ์ ํ๋ฒํธ ๋ชฉ๋ก (0) | 2023.09.03 |
---|---|
[Python] ํ๋ก๊ทธ๋๋จธ์ค ๊ฒ์ ๋งต ์ต๋จ๊ฑฐ๋ฆฌ & ๋ฐฑ์ค 16953 (0) | 2023.08.31 |
[Python] ๋ฐฑ์ค 16165 & ๋ฐฑ์ค 2908 (0) | 2023.08.28 |
[Python] ๋ฐฑ์ค 1916 & ๋ฐฑ์ค 2309 (0) | 2023.08.27 |
[Python] ๋ฐฑ์ค 1743 & 1303 (0) | 2023.08.27 |