Editorial for WC '17 Contest 4 J4 - Efficiency
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Let denote the cell in row and column of the grid. We'll first need to find Hawkeye's position . To do so, we can iterate over all cells in the grid, and when we encounter a cell with the value H
, we can set to and to .
From there, we'll need to consider all four possible directions for Hawkeye's shot, simulating how many dead soldiers each of them would result in and then using the maximum of the four values as our answer. To simulate Hawkeye shooting North, we can iterate a variable between and (inclusive), while counting the number of cells with the value C
. The other three directions can be handled similarly.
Comments