Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- N=int(sys.stdin.readline())
- seq=list(map(int,sys.stdin.readline().split()))
- INF=1000000000
- ans=[INF for i in range (N)]
- ptr=INF
- for i in range (N) :
- j=N-i-1
- if(seq[j]==0):
- ptr=j
- ans[j]=ptr-j
- ptr=-INF
- for i in range (N) :
- if(seq[i]==0):
- ptr=i
- ans[i]=min(ans[i], i-ptr)
- answer = ' '.join(map(str, ans))
- sys.stdout.write(answer)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement