Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. from sys import stdin
  2. def kg():
  3. n,m = map(int,input().split())
  4. qw = [[[0,0] for i in range(n+1)] for i in range(m+1)]
  5. pppp = int(input())
  6. for i in range(pppp):
  7. a,b = map(int,stdin.readline().split())
  8. qw[b][a][1] = 1
  9.  
  10.  
  11. for i in range(m+1):
  12. for u in range(n+1):
  13. if u == i == 0:
  14. continue
  15. q = []
  16. if qw[i][u][1] == 1:
  17.  
  18.  
  19. q.append(qw[i-1][u-1][0]+(100**2+100**2)**0.5)
  20. if i != 0:
  21.  
  22.  
  23. q.append(qw[i-1][u][0]+100)
  24. if u != 0:
  25.  
  26.  
  27. q.append(qw[i][u-1][0]+100)
  28. qw[i][u][0] = min(q)
  29. print(int(round(min(q),0)))
  30.  
  31. kg()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement