UVa 11205 The broken pedometer: enumerating good questions & skillfully using binary

Source: Internet
Author: User
Tags time limit

11205-the Broken Pedometer

Time limit:3.000 seconds

Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=107&page=show_ problem&problem=2146

The Problem

A marathon runner uses a pedometer with which it has problems. In the pedometer the symbols are represented by seven segments (or LEDs):

But the pedometer does not work properly (possibly the sweat affected the batteries) and only some of the LEDs active. The runner wants to know if all possible symbols:

can be correctly identified. For example, when the active LEDs are:

Numbers 2 and 3 are seen as:

So they cannot to be distinguished. But when the active LEDs are:

The numbers are seen as:

And all of them have a different representation.

Because the runner teaches algorithms at University, and him has some hours to do you are running, he has thought up A programming problem which generalizes the problem of his sweat pedometer. The problem consists of obtaining the minimum number of active LEDs necessary to identify each one of the symbols, given a Number P of LEDs, and N symbols to is represented with this LEDs (along with the codification of each symbol).

For example, in the previous sample P = 7 and N = 10. Supposing the LEDs are numbered as:

The Codification the symbols is: "0" = 1 1 1 0 1 1 1; "1" = 0 0 1 0 0 1 0; "2" = 1 0 1 1 1 0 1; "3" = 1 0 1 1 0 1 1; "4" = 0 1 1 1 0 1 0; "5" = 1 1 0 1 0 1 1; "6" = 1 1 0 1 1 1 1; "7" = 1 0 1 0 0 1 1; "8" = 1 1 1 1 1 1 1; "9" = 1 1 1 1 0 1 1. In this case, LEDs 5 and 6 can be suppressed without losing information, so the solution is 5.

The Input

The input file consists of a-a and the number of problems to solve. Each problem consists of a, a I with the number of LEDs (P), a second line with the number of symbols (n), and N Lin Es one with the codification of a symbol. For each symbol, the codification are a succession of 0s and 1s, with a space between them. A 1 means the corresponding LED is part of the codification of the symbol. The maximum value of P is-maximum value of N is 100. All the symbols have different codifications.

The Output

This article URL address: http://www.bianceng.cn/Programming/sjjg/201410/45368.htm

The output would consist of a line for each problem, with the minimum number of active LEDs necessary to identify all the G Iven symbols.

Sample Input

2
7
of
1 1 1
0 1 1 1 0 0 1 0 0 1 0 1 0 1 1 1 0 1 1 0 1 1 0 1 1 0 1 1 1 0 1 0 1 1 0 1 0
1 1 0 1 1 1 1 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 6 0 1 1 1 0 0 1 0 0 0
C24/>0 1 1 0 0 0

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.