Advertisement
simeonshopov

Battle Ships

Dec 6th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. n = int(input())
  2. ships = 0
  3. rows = []
  4.  
  5. for i in range(n):
  6.     row = [int(x) for x in input().split()]
  7.     rows.append(row)
  8.  
  9. squares = input().split()
  10.  
  11. for spot in squares:
  12.     spot = [int(x) for x in spot.split('-')]
  13.     row_place = spot[0]
  14.     col_place = spot[1]
  15.     if rows[row_place][col_place] > 0:
  16.       rows[row_place][col_place] -= 1
  17.       if rows[row_place][col_place] == 0:
  18.         ships += 1
  19.  
  20. print(ships)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement