Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e3fa049

Browse files
committed
암벽 등반
1 parent c59b10a commit e3fa049

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

‎Code-Test-Study‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 17afae93ef94ad5102e80a34841b766f20301a11

‎JongHo/BOJ/2412.py‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from collections import deque
2+
import sys
3+
4+
input = sys.stdin.readline
5+
n, T = map(int, input().split())
6+
7+
cor = set()
8+
for _ in range(n):
9+
x, y = map(int, input().split())
10+
cor.add((x, y))
11+
12+
dx = [-2, -1, 0, 1, 2]
13+
dy = [-2, -1, 0, 1, 2]
14+
15+
q = deque()
16+
q.append([0, 0, 0])
17+
18+
while q:
19+
x, y, cnt = q.popleft()
20+
if y == T:
21+
print(cnt)
22+
exit(0)
23+
for i in range(5):
24+
for j in range(5):
25+
nx = x + dx[i]
26+
ny = y + dy[j]
27+
if (nx, ny) in cor:
28+
q.append([nx, ny, cnt + 1])
29+
cor.remove((nx, ny))
30+
print(-1)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /