viligen

battle_ships

Nov 2nd, 2021
605
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. rows = int(input())
  2.  
  3. destroyed = 0
  4. field = []
  5. for i in range(rows):
  6.     field.append(list(map(int, input().split())))
  7.  
  8. attack = input().split()
  9.  
  10. for j in range(len(attack)):
  11.     current_attack = attack[j].split("-")
  12.     curr_row = int(current_attack[0])
  13.     curr_col = int(current_attack[1])
  14.  
  15.     if field[curr_row][curr_col] > 0:
  16.         field[curr_row][curr_col] -= 1
  17.         if field[curr_row][curr_col] == 0:
  18.             destroyed += 1
  19.  
  20. print(destroyed)
  21.  
Advertisement
Add Comment
Please, Sign In to add comment