-
Notifications
You must be signed in to change notification settings - Fork 1
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
9-alstjr7437 #29
9-alstjr7437 #29
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.
ν΄μ€μ 보면μ μ΄ν΄κ° μλλ λΆλΆμ΄ μλλ°, μμ°¨μ μΌλ‘ λ²νΌμ λλ₯΄λ κ²μ΄ μλ λ€λ₯Έ μμΉμ λ²νΌμ λ¨Όμ λλ₯΄λ κ²μ΄ μ΅μμ λ²νΌ λλ₯΄λ νμκ° λ μλ μμ§ μλμ? λ€λ₯Έ ν΄μ€λ€λ 보λλ° λ―Όμλκ³Ό κ°μ ν΄μ€μ΄λλΌκ΅¬μ..! π€
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.
import sys
input = sys.stdin.readline
N = int(input())
_init = list(map(int, input().rstrip()))
_goal = list(map(int, input().rstrip()))
tr_init = _init.copy()
tr_init[:2] = [0 if j else 1 for j in _init[:2]]
def return_cnt(_init, _goal):
cnt = 0
for i in range(1,len(_init)):
if _init[i-1] == _goal[i-1]:
continue
_init[i-1:i+2] = [0 if j else 1 for j in _init[i-1:i+2]]
cnt += 1
if _init == _goal:
return cnt
else:
return -1
tr = return_cnt(tr_init, _goal)
not_tr = return_cnt(_init, _goal)
if not_tr >= 0:
print(not_tr)
elif tr >= 0:
print(tr+1)
else:
print(-1)
μ²μμλ λ€λ₯Έ μ ꡬμμ λ³νμ μλνμλλ° κ·Έλ¬λ©΄ μμ μ ꡬ μνκ° λ³΄μ₯μ΄ μ λλλΌκ΅¬μ.
κ·Έλμ λ°λ‘ λ€ μ ꡬμμ λ³ννλ κ±Έλ‘ ν΄μ μ½λλ₯Ό μ§°λλ° λ§λ§ν΄μ λ―Όμλ νμ΄λ₯Ό μ’ μ°Έκ³ νμ΅λλ€.
0λ²μ§Έ μΈλ±μ€ λ³ν μ λ¬΄κ° μ€μνλ κ±°λ€μ..
1 0 1 1 1λ² ν΄λ¦ > 4λ² ν΄λ¦ 0 1 0 0 0 0 0 0 0 3λ² ν΄λ¦ 0 1 1 1 0 μμ κ°μ΄ μ΄μ§νΌ μ΄λ€ λ²νΌμ λλ₯΄λμ§λ λκ°κ² λμ€κ³ λ²νΌ νμμ μ°¨μ΄λ μμ κ² κ°μμ!! |
π λ¬Έμ λ§ν¬
μ ꡬμ μ€μμΉ
βοΈ μμλ μκ°
1μκ° 20λΆ
β¨ μλ μ½λ
그리λμ κ°λ μ μ μκ°νλ©΄μ μ ꡬλ₯Ό μ³λ€λ³΄κ³ μμΌλ λ¬Έλ© λ μ€λ₯΄λ€κ΅¬μ..
μ²μμλ μμ μμ 000 -> 010 λ§λ€κΈ° μλλ°
0 0 0 -> 1 1 0 -> 1 0 1 -> 0 1 0 μ΄ μκ³
0 0 0 -> 1 1 0 -> 0 0 1 -> 0 1 0 μ΄ μμμ΅λλ€.
μ λκ°μ μ°¨μ΄μ μΌλ‘
κ·Έλ κ² ν΄μ μ μͺ½ μ ꡬλΆν° κ³μν΄μ κ²°κ³Όκ°μ λ§μΆ°κ°λ©΄ λμ§ μμκΉ μκ°ν΄μ μμλμ΄λ₯Ό λμ΅λλ€
μλ₯Όλ€μ΄ 5λ²κΉμ§ μμΌλ©΄ 0λ² λ¨Όμ νκ²μ λ§κ² 1λ² λ§κ² μ~~~ νλ©΄ λλλΌκ΅¬μ.
μμ κ°μ΄ νλλ° λ· λΆλΆμ κ·Έλ₯ κ΅μ²΄λ₯Ό ν΄μ£Όλ©΄ λλλ°
π‘ 0λ² λ²νΌμ μμΈλ₯Ό λ°λ‘ λ¬μΌνλλΌκ³ μ
μμ κ°μ΄ 그리λλ₯Ό ν΅ν νμ¬ μν©μμ κ°μ₯ μ’μ보μ΄λ λ²νΌμ λλ¬ μ ꡬλ₯Ό ν€λλ‘ νμ΅λλ€!
μ½λλ λͺλ² νκ°λ¦¬κΈ΄ νμ§λ§
μ¬μ€ μΆλ ₯μ λ κΉλνκ² λ§λ€ μ μμ κ² κ°μλ° λκ° λΉλͺ μ μ§λ¬μ...βοΈ μ΅μ’ μ½λ
π μλ‘κ² μκ²λ λ΄μ©
그리λ κ°λ μ μ΄μ μ΄λμ λ μ 리νκ³ μ€λ λ¬Έμ λ₯Ό νμ΄λ΄€λλ° νλ €μ κΈ°λΆμ΄ μ’λ€μ!! κ·Όλ° 0λ² λ²νΌ μ²λ¦¬λ₯Ό λ°λ‘ ν΄μ€μΌ νλ λΆλΆμμ λ§νμ μ μ μΈν°λ· μ°Έμ‘°λ₯Ό νμμ΅λλ€!