Skip to content

Commit 56543cb

Browse files
committed
[BOJ]#1783. 병든나이트/실버3/실패
https://www.acmicpc.net/problem/1783
1 parent e3255ce commit 56543cb

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

Hongjoo/백준/병든나이트.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""
2+
실버3
3+
https://www.acmicpc.net/problem/1783
4+
5+
#문제 : 그래프탐색(DFS , BFS)
6+
- NxM 의 왼쪽 아래 칸 시작
7+
- 4가지 방법으로 이동
8+
(1) 2칸 위 , 1칸 오른쪽
9+
(2) 1칸 위로 2칸 오른쪽
10+
(3) 1칸 아래로 , 2칸 오른쪽
11+
(4) 2칸 아래 , 1칸 오느ㅜㄹ쪽
12+
- goal) 방문할 수 있는 "최대 칸 개수" 구하기
13+
14+
# 조건
15+
- <이동횟수가 4번 이상 -> 이동 방법 모두 사용
16+
- < 4번 이하 - 제약 없음
17+
18+
19+
"""
20+
n, m = map(int, input().split())
21+
22+
result = 0
23+
# n이 1일 때 무조건 1
24+
if n == 1:
25+
result = 1
26+
# n이 2일 때
27+
elif n == 2:
28+
if m >= 1 and m <= 6: #m이 1~6일 때
29+
result = (m + 1) // 2
30+
elif m >= 7: #7이상일 때
31+
result = 4
32+
# n이 3 이상일 때
33+
elif n >= 3:
34+
if m <= 6: #m이 1~6일 때
35+
result = min(m, 4)
36+
elif m >= 7: #m이 7 이상일 때
37+
result = m - 2
38+
print(result)

0 commit comments

Comments
 (0)