TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

Alice has received a hypercube toy as her birthday present. This hypercube
has 16 vertices, numbered from 1 to 16, as illustrated below. On every vertex,
there is a light bulb that can be turned on or off. Initially, eight of the light
bulbs are turned on and the other eight are turned off. You are allowed to switch
the states of two adjacent light bulbs with different states (“on” to “off”, and
“off” to “on”; specifically, swap their states) in one operation.


Given the initial state of the lights, your task is to calculate the minimum
number of steps needed to achieve the target state, in which the light bulbs on
the sub cube (1,2,3,4)-(5,6,7,8) are turned off, and the rest of them are turned
on.


Input Format

There are multiple test cases. The first line of the input contains an integer
T, meaning the number of the test cases. There are about 10000 test cases in total.
For each test case there are 16 numbers in a single line, the i-th number is 1
meaning the light of the i-th vertex on the picture is on, and otherwise it’s
off.

Output Format

For every test cases output a number with case number meaning the minimum steps
needed to achieve the goal. If the number is larger than 3, you should output
“more”.

Sample Input 1

3 
0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 
0 1 0 0 0 0 0 0 1 0 1 1 1 1 1 1 
0 0 0 0 0 0 1 0 1 0 1 1 1 1 1 1

Sample Output 1

Case #1: 0
Case #2: 1
Case #3: more

Hints

Problem Source

Migrated from old NTUJ.

2009Shanghai

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 5000 65536 2048