Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n, m = (int(x) for x in input().split(", "))
- time_left = 16
- defuse_time = 4
- map_matrix = []
- ct_position = None
- bomb_position = None
- directions = {"up": (-1, 0), "down": (1, 0), "left": (0, -1), "right": (0, 1)}
- for r in range(n):
- row_data = list(input())
- map_matrix.append(row_data)
- for c in range(m):
- if row_data[c] == "C":
- ct_position = (r, c)
- if row_data[c] == "B":
- bomb_position = (r, c)
- while time_left > 0:
- command = input()
- if command == "defuse":
- if ct_position == bomb_position:
- if time_left >= defuse_time:
- map_matrix[ct_position[0]][ct_position[1]] = "D"
- time_left -= defuse_time
- print("Counter-terrorist wins!")
- print(f"Bomb has been defused: {time_left} second/s remaining.")
- break
- else:
- map_matrix[ct_position[0]][ct_position[1]] = "X"
- time_needed = defuse_time - time_left
- print(f"Terrorists win!\nBomb was not defused successfully!\nTime needed: {time_needed} second/s.")
- break
- else:
- time_left -= 2
- continue
- else:
- row = directions[command][0] + ct_position[0]
- col = directions[command][1] + ct_position[1]
- if row in range(n) and col in range(m):
- current_cell_value = map_matrix[row][col]
- ct_position = (row, col)
- if current_cell_value == "T":
- map_matrix[row][col] = "*"
- print("Terrorists win!")
- break
- time_left -= 1
- else:
- print("Terrorists win!\nBomb was not defused successfully!\nTime needed: 0 second/s.")
- for row in map_matrix:
- print(*row, sep="")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement