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 f451f4a

Browse files
[Silver II] Title: 점프, Time: 76 ms, Memory: 30840 KB -BaekjoonHub
1 parent 8da0d21 commit f451f4a

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# [Silver II] 점프 - 1890
2+
3+
[문제 링크](https://www.acmicpc.net/problem/1890)
4+
5+
### μ„±λŠ₯ μš”μ•½
6+
7+
λ©”λͺ¨λ¦¬: 30840 KB, μ‹œκ°„: 76 ms
8+
9+
### λΆ„λ₯˜
10+
11+
λ‹€μ΄λ‚˜λ―Ή ν”„λ‘œκ·Έλž˜λ°(dp)
12+
13+
### 문제 μ„€λͺ…
14+
15+
<p&g×ば぀N κ²Œμž„νŒμ— μˆ˜κ°€ μ ν˜€μ Έ μžˆλ‹€. 이 κ²Œμž„μ˜ λͺ©ν‘œλŠ” κ°€μž₯ μ™Όμͺ½ μœ„ μΉΈμ—μ„œ κ°€μž₯ 였λ₯Έμͺ½ μ•„λž˜ 칸으둜 κ·œμΉ™μ— 맞게 점프λ₯Ό ν•΄μ„œ κ°€λŠ” 것이닀.</p>
16+
17+
<p>각 칸에 μ ν˜€μžˆλŠ” μˆ˜λŠ” ν˜„μž¬ μΉΈμ—μ„œ 갈 수 μžˆλŠ” 거리λ₯Ό μ˜λ―Έν•œλ‹€. λ°˜λ“œμ‹œ 였λ₯Έμͺ½μ΄λ‚˜ μ•„λž˜μͺ½μœΌλ‘œλ§Œ 이동해야 ν•œλ‹€. 0은 더 이상 진행을 λ§‰λŠ” 쒅착점이며, 항상 ν˜„μž¬ 칸에 μ ν˜€μžˆλŠ” 수만큼 였λ₯Έμͺ½μ΄λ‚˜ μ•„λž˜λ‘œ κ°€μ•Ό ν•œλ‹€. ν•œ 번 점프λ₯Ό ν•  λ•Œ, λ°©ν–₯을 λ°”κΎΈλ©΄ μ•ˆ λœλ‹€. 즉, ν•œ μΉΈμ—μ„œ 였λ₯Έμͺ½μœΌλ‘œ 점프λ₯Ό ν•˜κ±°λ‚˜, μ•„λž˜λ‘œ 점프λ₯Ό ν•˜λŠ” 두 경우만 μ‘΄μž¬ν•œλ‹€.</p>
18+
19+
<p>κ°€μž₯ μ™Όμͺ½ μœ„ μΉΈμ—μ„œ κ°€μž₯ 였λ₯Έμͺ½ μ•„λž˜ 칸으둜 κ·œμΉ™μ— 맞게 이동할 수 μžˆλŠ” 경둜의 개수λ₯Ό κ΅¬ν•˜λŠ” ν”„λ‘œκ·Έλž¨μ„ μž‘μ„±ν•˜μ‹œμ˜€.</p>
20+
21+
### μž…λ ₯
22+
23+
<p>첫째 쀄에 κ²Œμž„ 판의 크기 N (4 ≀ N ≀ 100)이 μ£Όμ–΄μ§„λ‹€. κ·Έ λ‹€μŒ N개 μ€„μ—λŠ” 각 칸에 μ ν˜€μ Έ μžˆλŠ” μˆ˜κ°€ Nκ°œμ”© μ£Όμ–΄μ§„λ‹€. 칸에 μ ν˜€μžˆλŠ” μˆ˜λŠ” 0보닀 ν¬κ±°λ‚˜ κ°™κ³ , 9보닀 μž‘κ±°λ‚˜ 같은 μ •μˆ˜μ΄λ©°, κ°€μž₯ 였λ₯Έμͺ½ μ•„λž˜ μΉΈμ—λŠ” 항상 0이 μ£Όμ–΄μ§„λ‹€.</p>
24+
25+
### 좜λ ₯
26+
27+
<p>κ°€μž₯ μ™Όμͺ½ μœ„ μΉΈμ—μ„œ κ°€μž₯ 였λ₯Έμͺ½ μ•„λž˜ 칸으둜 문제의 κ·œμΉ™μ— 맞게 갈 수 μžˆλŠ” 경둜의 개수λ₯Ό 좜λ ₯ν•œλ‹€. <span style="line-height:1.6em">경둜의 κ°œμˆ˜λŠ” 2</span><sup style="line-height:1.6em">63</sup><span style="line-height:1.6em">-1보닀 μž‘κ±°λ‚˜ κ°™λ‹€.</span></p>
28+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# 점프 - λ‹€μ΄λ‚˜λ―Ή ν”„λ‘œκ·Έλž˜λ°
2+
N = int(input())
3+
board = [list(map(int, input().split())) for _ in range(N)]
4+
dp = [[0] * N for _ in range(N)]
5+
6+
def fn(x, y):
7+
if x == 0 and y == 0:
8+
dp[x][y] = 1
9+
return
10+
down = 0
11+
for i in range(x): down += dp[i][y] if board[i][y] == x - i else 0
12+
13+
right = 0
14+
for i in range(y): right += dp[x][i] if board[x][i] == y - i else 0
15+
16+
dp[x][y] = down + right
17+
return
18+
19+
for i in range(N):
20+
for j in range(N):
21+
fn(i, j)
22+
23+
print(dp[N-1][N-1])

0 commit comments

Comments
(0)

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /