Data Structures & AlgorithmsHardCodeforces Div2 B-D · ICPC regional

On a line with cells 1 to 10, a lamp at position p lights cells p-2 to p+2. Lamps are placed at positions 1, 4, 6, 9. Do they light every cell from 1 to 10?

  1. A. yes
  2. B. no, cell 10 is missing only
  3. C. yes, but cell 5 is unlit
  4. D. cannot tell without lamp colours

Correct answer: A. yes

Each lamp covers five cells around its position. Cell 10 is lit by the lamp at 9 (covering 7 to 11), and cell 5 is lit by the lamp at 4 (covering 2 to 6).

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic