Advertisement
makut

Untitled

Apr 16th, 2014
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. import sys
  2.  
  3. n = int(input())
  4. way_1 = list(map(int, input().split()))
  5. way_2, deadlock = [], []
  6. result = []
  7. for i in range(1, n + 1):
  8. if i in way_1:
  9. need_index = way_1.index(i) + 1
  10. result.append([1, need_index])
  11. deadlock.extend(way_1[:need_index])
  12. del way_1[:need_index]
  13.  
  14. way_2.append(deadlock.pop())
  15. result.append([2, 1])
  16. else:
  17. if deadlock[-1] == i:
  18. way_2.append(deadlock.pop())
  19. result.append([2, 1])
  20. else:
  21. print(0)
  22. sys.exit()
  23. for action in result:
  24. print(' '.join(map(str, action)))
  25. # 4 3 2 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement