-
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
13-H0ngJu #181
Conversation
37-Munbin-Lee
41-tgyuuAn
38-Munbin-Lee
42-tgyuuAn
51-tgyuuAn
42-pknujsp
43-pknujsp
νμ₯¬λ₯΄ μ½λ λΈλ νμ΄λΌμ΄ν μλμ΄μμ΄μ μ κ° νμ΄λΌμ΄ν λ£μ΄λ¨μλλ€! |
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.
μλ......... μκ°ν΄λ³΄λκΉ Nμ΄ 50λ§λ°μ μλλκΉ λΈλ£¨νΈ ν¬μ€λ‘ ν μ μμλ€μ....
import sys
def input(): return sys.stdin.readline().rstrip()
INF = int(1e9)
N = int(input())
M = int(input())
not_working_buttons = set(input().split())
working_buttons = set(str(x) for x in range(10))
working_buttons -= not_working_buttons
min_gap = max(100 - N, N - 100)
answer = min_gap
def dfs(num, depth, working_buttons):
global answer, min_gap
if len(str(N))-1 <= depth and depth <= len(str(N))+1:
gap = max(int(num) - N, N - int(num))
if min_gap >= gap:
answer = min(answer,(depth + gap))
min_gap = gap
if depth == len(str(N))+1: return
for button in working_buttons:
dfs(num+button, depth+1, working_buttons)
min_gap = max(100 - N, N - 100)
for button in working_buttons:
if button == "0":
gap = N
if min_gap > gap:
answer = N+1
min_gap = N
continue
dfs(button, 1, working_buttons)
print(answer)
λ°λΉ μ μκ³ λ¦¬μ¦ μ’ μ¬μλλ κ° λ€ μμλλ΄λλ€.................
λ°λ‘ DFSκ° λ μ¬λλλ° λΈλ£¨νΈν¬μ€λ‘ νλ©΄ λ μ¬μ μλ€......................μ...............................
μ€λ²μμ§λμ΄λ§ γ γ γ γ γ γ γ γ γ γ γ γ γ γ γ γ γ
π λ¬Έμ λ§ν¬
리λͺ¨μ»¨
βοΈ μμλ μκ°
1μκ° +a
β¨ μλ μ½λ
μ²μ λ¬Έμ λ₯Ό λ³΄κ³ κ΅¬ν or μμ νμμ μκ°νμ΅λλ€.
μ΄λ»κ² μ κ·Όν΄μΌκ² λ€! λΌλκ² λ μ€λ₯΄μ§ μλλΌκ³ μ
μλ μ½λλ μλμ κ°μ΅λλ€.
μ¬κΈ°μ μ½κ° μ£Όμν΄μΌ ν μ μ΄ μμ΅λλ€.
μ λ N<=500,000μ΄λΌμ forλ¬Έμ λ°λ³΅λ¬Έ λ²μλ range(500001)λ‘ μ‘μμ΅λλ€. κ·Έλ°λ°, N = 500000, M = 8, btn = [0 2 3 4 6 7 8 9]μΈ κ²½μ°μ λν΄μλ μ¬λ°λ₯Έ λ΅μ΄ λμ€μ§ μμμ΅λλ€.
μ΄ λΆλΆμμ λ§νμ μ§λ¬Έ κ²μνμ μ°Έκ³ νμμ΅λλ€.
μΌλ¨ forλ¬Έμ 500000κΉμ§μ λ²μμμλ§ λ릴 κ²½μ°, νΉμ μ±λμ λνμ¬ + λ₯Ό κ³ λ €ν λΏ, -λ₯Ό κ³ λ €νμ§ μμ΅λλ€.
μ¦, μλ μ±λλΆν° +νμ¬ target channelλ‘ κ°λ κ²μ΄ μλλΌ, μ μ±λμμ μλ μ±λλ‘ -νμ¬ target channelλ‘ κ°λ κ²½μ°λ₯Ό μκ°νλ©΄
λ°λ³΅λ¬Έμ λ²μλ 500,000 * 2μΈ 1,000,000κ° λ©λλ€.
π μλ‘κ² μκ²λ λ΄μ©