## CCC '09 S2 - Lights Going On and Off

View as PDF

Points: 10
Time limit: 1.0s
Memory limit: 64M

Problem type
##### Canadian Computing Competition: 2009 Stage 1, Senior #2

For your birthday, you have been given a grid of rows of lights, with each row containing lights. Lights can be in one of two states: on or off. For this question, the topmost row is row , and the bottom-most row is row . Also, beside all rows except the topmost row (row ), there is a button which can be pushed.

Pushing the button beside row will perform an "exclusive-or" operation on each light of row , which is described below. Consider column in row , where . If the lights in column of row and column of row are both the same (i.e., both on, or both off), then pushing the button beside row will cause the light in column of row to be off. If the lights in column of row and column of row are different (i.e., one is on, and the other is off), then pushing the button beside row will cause the light in column of row to be on. An example is shown below, for :

Column Numbers 1 2 3 4
Row on on off off
Row before button pushed on off on off
Row after button pushed off on on off

You are told which lights are initially on and which are initially off. You must calculate how many different light patterns are possible for the bottom row by any sequence of button pushes. Each button may only be pressed once, but in any order.

#### Input Specification

The first line of input will contain the integer , the number of rows. The second line of input will contain the integer , the number of lights per row. The next lines of input will contain integers, where the integer will either be (to indicate "off") or (to indicate "on"). Pairs of consecutive integers will be separated by one space character. These lines will be given in topdown order: that is, the third line of input will be the description of row , the fourth line will be , and so on, until the last line describes the bottom row.

#### Output Specification

Output the number of possible light patterns of the bottom row.

#### Sample Input

4
3
0 0 1
0 1 1
1 0 1
0 0 1

#### Sample Output

4

CCC problem statements in large part from the PEG OJ

• commented on Feb. 16, 2021, 10:01 a.m.

i guess these are the kinds of bday presents ppl get in dmojistan

• commented on May 24, 2020, 3:18 p.m.

I've never been more confused in my life

• commented on Nov. 24, 2019, 10:48 a.m.

worst birthday present ever

• commented on Nov. 24, 2019, 9:17 a.m. edited

This comment is hidden due to too much negative feedback. Click here to view it.

• commented on Dec. 23, 2020, 1:08 p.m. edit 2

why did this get so much hate lmao

edit: apparently I'm not supposed to question that LMAO

• commented on Aug. 16, 2019, 2:28 p.m.

This comment is hidden due to too much negative feedback. Click here to view it.

• commented on June 25, 2019, 4:12 p.m.

arock is listed twice under Best Submissions (https://dmoj.ca/problem/ccc09s2/rank/3#submissions-table).

• commented on Dec. 16, 2018, 5:17 p.m.

what kind of parent would buy their kids this

• commented on March 23, 2018, 12:08 p.m. edited

do you have to press every button?

update:no you don't