Advertisement
karupayun

tap17/e_nico.cpp

Oct 22nd, 2017
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. #!/usr/bin/env python3
  2.  
  3. NCARDS = 7
  4.  
  5. def minimax(mano, pie):
  6.     if not mano: return 0
  7.     ans = -10
  8.     for x in mano:
  9.         best = -10
  10.         for y in pie:
  11.             if x < y: best = max(best, -minimax(mano - {x}, pie - {y}) - 1)
  12.             else: best = max(best, 1 + minimax(pie - {y}, mano - {x}))
  13.         ans = max(ans, -best)
  14.     return ans
  15.  
  16. mano = set(map(int,input().split()))
  17. pie = set(range(1,NCARDS+1)) - mano
  18. pie.remove(max(pie))
  19. print('S' if minimax(mano,pie) > 0 else 'N')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement