daily pastebin goal
13%
SHARE
TWEET

advent.py 2017-12-07

a guest Dec 7th, 2017 18 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. from functools import lru_cache
  2. import sys
  3.  
  4. INF = 999999999
  5.  
  6. def mkmat(sx, sy, val=0):
  7.     return [[val for _ in range(sx)] for _ in range(sy)]
  8.  
  9. def fw(m):
  10.     for k in range(len(m)):
  11.         for i in range(len(m)):
  12.             for j in range(len(m)):
  13.                 m[i][j] = min(m[i][j], m[i][k] + m[k][j])
  14.  
  15. def get1(cvt=str):
  16.     xs = []
  17.     for line in sys.stdin:
  18.         line = line.strip()
  19.         if line:
  20.             xs.append(cvt(line))
  21.     return xs
  22.  
  23. def get2(cvt=str):
  24.     xs = []
  25.     for line in sys.stdin:
  26.         line = line.strip()
  27.         if line:
  28.             xs.append([cvt(part) for part in line.split()])
  29.     return xs
  30.  
  31. memo = lru_cache(maxsize=None)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top