Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. from itertools import permutations
  2. from functools import reduce
  3. print(*next(
  4. reduce(
  5. lambda x, y: filter(
  6. lambda z: (z[y[0] - 1] < z[y[1] - 1] and z[y[2] - 1] > z[y[3] - 1]) \
  7. or (z[y[0] - 1] > z[y[1] - 1] and z[y[2] - 1] < z[y[3] - 1]),
  8. x
  9. ),
  10. [permutations(range(
  11. 1,
  12. int(open('input.txt').readline().split()[0]) + 1
  13. )
  14. )
  15. ] +
  16. list(
  17. map(
  18. lambda x: tuple(map(int, str.split(x))),
  19. open('input.txt').readlines()[1:]
  20. )
  21. )
  22. ),
  23. [0]
  24. ))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement