GeorgiLukanov87

ship_battle_matrix

Jun 5th, 2022 (edited)
73
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.  
  3. all_ships = []
  4. for iterations in range(1, n+1):
  5.     field = [list(map(int,input().split()))]
  6.     all_ships += field
  7.  
  8. attacked = input().split(" ")
  9.  
  10. destroyed = 0
  11. for shot in range(len(attacked)):
  12.     current_attack = attacked[shot]
  13.     row = int(current_attack[0])
  14.     col = int(current_attack[2])
  15.     all_ships[row][col] -= 1
  16.  
  17.     if all_ships[row][col] == 0:
  18.         destroyed += 1
  19.  
  20. print(destroyed)
Add Comment
Please, Sign In to add comment