-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
84-tgyuuAn #261
84-tgyuuAn #261
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'μ΄ μ―€μ΄λ©΄ ν΅κ³Όλ€' λ§ μ¬λ¬λ² μΈμ³€λ€μ γ γ ...
- λΆμ΄λ μ§νμ΄ qλ₯Ό λμμ λλ €μΌ ν¨
- qλ₯Ό λ릴 λ, μ΄λ² ν΄μ λ°μ΄ν°λ§ λ°λ‘ κ΄λ¦¬ν΄μ£Όμ΄μΌ ν¨
- λΆμ΄ μ¬λ¬ κ°μΌ μ μμ << μ μ΄κ±΄ κ²μν λ³΄κ³ μ°Ύμμ΅γ΄λγ ... 11%μμ μ λμ΄κ°λλΌκ³ μ,.....
λΆλͺ BFSμΈλ° λ―μ€κ² λκ»΄μ§λ λ¬Έμ μλ€μ!! μκ³ νμ ¨μ΅λλ€.
import sys
from collections import deque
def input() : return sys.stdin.readline().rstrip()
R, C = map(int, input().split())
maze = [list(input()) for _ in range(R)]
fx, fy = 0,0
jx, jy = 0,0
time = 1
dir = [(0,1), (0,-1), (1,0), (-1,0)]
# # λ²½ . κΈΈ J μ§νμ΄ F λΆ
j_q = deque() # μ 체 κ²½λ‘
f_q = deque()
for r in range(R):
for c in range(C):
if maze[r][c] == "J":
j_q.append((r,c))
if maze[r][c] == "F":
f_q.append((r,c))
success = 0
while j_q:
f_next = deque()
while f_q:
# μ΄λ² ν΄μ λΆλ§ λ²μ§λλ‘ ν΄μΌν¨
fx, fy = f_q.popleft()
for dx, dy in dir:
if 0 <= fx+dx < R and 0 <= fy+dy < C and maze[fx+dx][fy+dy] == '.':
maze[fx+dx][fy+dy] = "F"
f_next.append((fx+dx,fy+dy))
f_q = f_next
j_next = deque()
while j_q:
# μ΄λ² ν΄μ μ§νμ΄λ§ νμΈνλ©΄ λ¨
jx, jy = j_q.popleft()
for dx, dy in dir:
if not (0 <= jx+dx < R and 0 <= jy+dy < C):
print(time)
success = 1
break
else:
if maze[jx+dx][jy+dy] == '.':
maze[jx+dx][jy+dy] = "J"
j_next.append((jx+dx,jy+dy))
if success: break
j_q = j_next
time += 1
if success: break
if not success:
print("IMPOSSIBLE")
fire = [] | ||
|
||
## 보λλ₯Ό λ§λλλ°, κ°μ₯μ리λ₯Ό λμ°© μ§μ (*)μΌλ‘ κ°μΌλ€. | ||
board = [["*" for _ in range(C+2)]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
νΉμ μλΆλΆ κ·Έλ₯ 보λ λ²μλ₯Ό λ²μ΄λλ (r,cκ° 0λ―Έλ§, R,C μ΄κ³ΌμΈ κ²½μ°) λ―Έλ‘ νμΆνλ€λκ±Έ μ μ μμ κ² κ°μλ° κ°μΌ μ΄μ κ° μλμ??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
νΉμ μλΆλΆ κ·Έλ₯ 보λ λ²μλ₯Ό λ²μ΄λλ (r,cκ° 0λ―Έλ§, R,C μ΄κ³ΌμΈ κ²½μ°) λ―Έλ‘ νμΆνλ€λκ±Έ μ μ μμ κ² κ°μλ° κ°μΌ μ΄μ κ° μλμ??
ν κ·Έλ₯ λ νΈνκ² κ°λ°νλ €κ³ κ·Έλ¬μ΅λλ€!!!!!!
λΆκΈ°μ²λ¦¬ν΄μ€μΌ ν κ² κ°μμ ...
π λ¬Έμ λ§ν¬
λΆ!
βοΈ μμλ μκ°
30λΆ
β¨ μλ μ½λ
μ΄ λ¬Έμ λ₯Ό ν λ μμ£Ό μ¬μ©λλ μ‘κΈ°μ μ΄ νλ μ¬μ©λλλ°,
λ¬Έμ μ μ΅μ’ λͺ©μ μ΄ λ°μΌλ‘ λκ° μ μλ μλλ₯Ό νλ¨νλ κ²μ΄λ―λ‘,
μ΄λ₯Ό μμ½κ² ꡬννλ λ°©λ²μ κΈ°μ‘΄μ μ£Όμ΄μ§ 보λμ μΈκ³½μ ν λ² κ°μΈμ£Όλ κ²μ΄λ€.
μ¬μ€ μ μ‘κΈ°μ λ§ ν°λνλ©΄ λ°λ‘ 골λ5 μ λ μμ€μ BFS λ¬Έμ λ‘ λ°λλ€.
μ¬κΈ°μλ μμ£Ό μ¬μν λν μΌμ΄ λ€μ΄κ°λλ°,
μ§νμ΄κ° κ° μ μλ κ³³κ³Ό λΆμ΄ νΌμ§λ κ³³ κ°κ° 2κ°μ νμ λν΄μ BFSλ₯Ό λλ €μΌνλλ°,
μ΄ λ μ κ²½μ¨μ€μΌ ν μ μ λΆμ΄ νΌμ§λ κ³³μ λ¨Όμ BFSλ₯Ό λλ¦° λ€,
μ§νμ΄κ° κ° μ μλ κ³³μ 체ν¬νλ κ²μ΄λ€.
λ§μ½ λ°λλ‘ νλ€λ©΄ μ§νμ΄κ° κ°λ κΈΈμ λΆμ΄ κ·Έ μκ°μ νΌμ Έλ²λ €μ μ§νμ΄κ° μ¬κ° λμ΄λ²λ¦΄ μλ μμ...!
μ λν μΌλ§ μ κ²½μ¨μ£Όλ©΄ μμ½κ² ν΄κ²° ν μ μλ€!
π μλ‘κ² μκ²λ λ΄μ©