CF47D.Safe

提高+/省选-

通过率:0%

时间限制:5.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Vasya tries to break in a safe. He knows that a code consists of n numbers, and every number is a 0 or a 1. Vasya has made m attempts to enter the code. After each attempt the system told him in how many position stand the right numbers. It is not said in which positions the wrong numbers stand. Vasya has been so unlucky that he hasn’t entered the code where would be more than 5 correct numbers. Now Vasya is completely bewildered: he thinks there’s a mistake in the system and it is self-contradictory. Help Vasya — calculate how many possible code variants are left that do not contradict the previous system responses.

瓦西娅试图破解一个保险箱。他知道密码由 nn 个数字组成,每个数字为 00 或 11。瓦西娅已进行了 mm 次密码输入尝试。每次尝试后,系统会告诉他有多少个位置上的数字是正确的(即与真实密码在该位置上的数字相同),但并未指出具体哪些位置正确。瓦西娅非常不走运,以至于他所有尝试中,正确数字的个数均未超过 55 个。现在瓦西娅完全困惑了:他认为系统存在错误,其反馈自相矛盾。请帮助瓦西娅——计算出所有与之前系统反馈均不矛盾的可能密码数量。

输入格式

The first input line contains two integers n and m (6 ≤ n ≤ 35, 1 ≤ m ≤ 10) which represent the number of numbers in the code and the number of attempts made by Vasya. Then follow m lines, each containing space-separated s__i and c__i which correspondingly indicate Vasya’s attempt (a line containing n numbers which are 0 or 1) and the system’s response (an integer from 0 to 5 inclusively).

第一行输入包含两个整数 nn 和 mm(6 ≤ n ≤ 356 \leq n \leq 35,1 ≤ m ≤ 101 \leq m \leq 10),分别表示密码中数字的个数以及 Vasya 所做的尝试次数。接下来是 mm 行,每行包含用空格分隔的 sis_i 和 cic_i,分别对应 Vasya 的一次尝试(一行包含 nn 个数字,每个数字为 00 或 11)以及系统给出的反馈(一个介于 00 到 55(含)之间的整数)。

输出格式

Print the single number which indicates how many possible code variants that do not contradict the m system responses are left.

输出一个单独的数字,表示剩余多少种可能的密码组合不与这 m 条系统反馈相矛盾。

输入输出样例

  • 输入#1

    6 2
    000000 2
    010100 4

    输出#1

    6
  • 输入#2

    6 3
    000000 2
    010100 4
    111100 0

    输出#2

    0
  • 输入#3

    6 3
    000000 2
    010100 4
    111100 2

    输出#3

    1

输入解题思路,AI测评打分。不知道怎么写?

首页