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
- s3 ์ด๋ฏธ์ง ๋ค์ด๋ก๋
- Entity
- s3 log ์ ์ฅ
- aws saa ํฉ๊ฒฉ
- docker compose
- AWS Certified Solutions Architect - Associate
- nGrinder
- docker
- redis ์กฐํ
- docker-compose kafka
- Codedeploy ์ค๋ฅ
- ์ ํจ์ค ์ค์ผ์ค๋ฌ
- prod docker-compose
- ์ ํจ์ค ๋น๋ ์ค๋ฅ
- ์๋ฐ
- ์๋ฒ ํฐ์ง๋ ๋์ปค ์ฌ์คํ
- redis ํ ์คํธ์ฝ๋
- ํ๋ก๊ทธ๋๋จธ์ค ํฉ์นํ์์๊ธ
- private subnet ec2 ๋ก์ปฌ ์ ์
- docker ps -a
- ๋ค์ค ์ปจํ ์ด๋
- ํ์ดํผ๋ฐ์ด์
- ์คํํ๋ ๋ฏธ์ค
- JPA
- ํ๋ก๊ทธ๋๋จธ์ค
- s3 ์ด๋ฏธ์ง ์ ์ฅ
- Kafka
- ํ๋ก๊ทธ๋๋จธ์ค ์ปฌ๋ฌ๋ง๋ถ
- jvm ๋ฐ๋ฐ๋ฅ๊น์ง ํํค์น๊ธฐ
- aws ์ฟ ํฐ
Archives
- Today
- Total
๐๐ข๐๐ โ๐๐๐ ๐๐๐ก๐๐ ๐๐๐๐โง
[Python] ํ๋ก๊ทธ๋๋จธ์ค ๊ฒ์ ๋งต ์ต๋จ๊ฑฐ๋ฆฌ & ๋ฐฑ์ค 16953 ๋ณธ๋ฌธ
๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ด๐ป/[๐๐ฒ๐ญ๐ก๐จ๐ง] ๐๐ฅ๐ ๐จ๐ซ๐ข๐ญ๐ก๐ฆ
[Python] ํ๋ก๊ทธ๋๋จธ์ค ๊ฒ์ ๋งต ์ต๋จ๊ฑฐ๋ฆฌ & ๋ฐฑ์ค 16953
๐คRyusun๐ค 2023. 8. 31. 23:27#ํ๋ก๊ทธ๋๋จธ์ค ๊ฒ์ ๋งต ์ต๋จ๊ฑฐ๋ฆฌ
from collections import deque
def solution(maps):
n, m = 0, 0
for _ in range(len(maps)):
n += 1
for _ in maps[0]:
m += 1
d_row = [0, -1, 0, 1]
d_col = [1, 0, -1, 0]
queue = deque()
queue.append([0,0])
maps[0][0] = 1
while queue:
x, y = queue.popleft()
if x == n-1 and y == m-1:
return maps[n-1][m-1]
for d in range(4):
nx = x + d_row[d]
ny = y + d_col[d]
if 0<= nx < n and 0<=ny<m:
if maps[nx][ny] == 1:
queue.append([nx,ny])
maps[nx][ny] = maps[x][y] + 1
return -1
#๋ฐฑ์ค 16953
n, m = map(int, input().split())
from collections import deque
def bfs(n, m):
queue = deque()
queue.append([n, 1])
visited = [n]
while queue:
x, cnt = queue.popleft()
if x == m:
return cnt
for nx in (x*2, int("".join([str(x), str(1)]))):
if 0<nx <= m and nx not in visited:
queue.append([nx, cnt+1]) #cnt๋ queue์ ๊ฐ์ด ๋ฃ์ด์ฃผ๋๊ฒ ์ค์ํ๋ค!!!
visited.append(nx)
return -1
print(bfs(n,m))
๋ฐฑ์ค 16953๋ฒ์ PyPy3๋ก ํด์ผ ์๊ฐ์ด๊ณผ๊ฐ ๋์ง ์๋๋คใ _ใ
'๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ด๐ป > [๐๐ฒ๐ญ๐ก๐จ๐ง] ๐๐ฅ๐ ๐จ๐ซ๐ข๐ญ๐ก๐ฆ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Python] ํ๋ก๊ทธ๋๋จธ์ค ์ต๋๊ฐ๊ณผ ์ต์๊ฐ & ํ๋ก๊ทธ๋๋จธ์ค ๋ค์ ํฐ ์ซ์ (0) | 2023.09.04 |
---|---|
[Python] ํ๋ก๊ทธ๋๋จธ์ค ๊ฑฐ๋ฆฌ๋๊ธฐ ํ์ธํ๊ธฐ & ํ๋ก๊ทธ๋๋จธ์ค ์ ํ๋ฒํธ ๋ชฉ๋ก (0) | 2023.09.03 |
[Python] ๋ฐฑ์ค 16956 (0) | 2023.08.29 |
[Python] ๋ฐฑ์ค 16165 & ๋ฐฑ์ค 2908 (0) | 2023.08.28 |
[Python] ๋ฐฑ์ค 1916 & ๋ฐฑ์ค 2309 (0) | 2023.08.27 |