Advertisement
Guest User

Untitled

a guest
Apr 19th, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. n, k = map(int , input().split(" "))
  2. films = [x for x in range(n + 1)]
  3. filmInDVD = 0
  4. filmseq = input().split(" ")
  5. for f in [int(j) for j in filmseq]:
  6.     if f != filmInDVD:
  7.         if filmInDVD != 0:
  8.             films[filmInDVD] = films[f]
  9.             films[f] = 0
  10.             filmInDVD = f
  11.         else:
  12.             films[f] = 0
  13.             films[0] = f
  14.             filmInDVD = f
  15. s = {k: f if f > 0 else -1 for f, k in enumerate(films)}
  16. for i in range(1, n + 1):
  17.     print(s[i], end=" ")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement