CF2233E1.Permutation Transmission (Easy Version)

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

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

题目描述

This is the easy version of the problem. In this version, the upper bound on nn and the sum of nn over all test cases is 2 0002\,000; furthermore, the maximum number of test cases is 200200.

There was a permutation pp of size nn∗^{\text{∗}}.

It was sent through a communication channel as follows: first, all 00-th bits of each number pip_{i} in the permutation were sent as one string of nn characters 0 and/or 1; then the 11-st bits were sent in the same format, and so on, up to the most significant bit of the number nn.

For example, for p=[3,1,2,4]p = [3, 1, 2, 4], the following three strings were sent:

  1. "1100";
  2. "1010";
  3. "0001".

You received all these strings, but the order in which each string corresponded to a bit was lost, that is, the strings arrived in arbitrary order. In the example above, the strings could have arrived in the order "1010", "0001", and "1100".

Your task is to determine how many possible original permutations pp could have been transmitted. It is possible that the data was corrupted during transmission, and then there is no valid original permutation pp.

∗^{\text{∗}}A permutation of size nn is an array of size nn where each integer from 11 to nn appears exactly once.

这是该问题的简单版本。在此版本中,nn 的上界以及所有测试用例中 nn 的总和为 2 0002\,000;此外,测试用例的最大数量为 200200。

存在一个长度为 nn∗^{\text{∗}} 的排列 pp。

它通过通信信道以如下方式发送:首先,将排列中每个数 pip_{i} 的所有第 00 位(最低位)作为一串长度为 nn 的由字符 0 和/或 1 组成的字符串发送;接着以相同格式发送所有第 11 位,依此类推,直至数字 nn 的最高有效位为止。

例如,对于 p=[3,1,2,4]p = [3, 1, 2, 4],共发送了以下三个字符串:

  1. "1100";
  2. "1010";
  3. "0001"。

你接收到了所有这些字符串,但丢失了每个字符串所对应的比特位编号(即字符串到达的顺序是任意的)。在上述例子中,字符串可能以 "1010"、"0001"、"1100" 的顺序到达。

你的任务是确定有多少种可能的原始排列 pp 可能被传输。传输过程中数据可能已损坏,此时不存在任何合法的原始排列 pp。

∗^{\text{∗}} 长度为 nn 的排列是指一个长度为 nn 的数组,其中 11 到 nn 的每个整数恰好出现一次。

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤2001 \le t \le 200). The description of the test cases follows.

The first line of each test case contains one integer nn (1≤n≤2 0001 \le n \le 2\,000).

The next ⌈log⁡2(n+1)⌉\lceil\log_2 (n + 1) \rceil lines of each test case contain the transmitted data in the received order. Each line consists of nn characters 00 and/or 11.

Additional input constraints:

  • the sum of nn over all test cases does not exceed 2 0002\,000.

每个测试包含多个测试用例。第一行包含测试用例的数量 tt(1≤t≤2001 \le t \le 200)。随后是各测试用例的描述。

每个测试用例的第一行包含一个整数 nn(1≤n≤2 0001 \le n \le 2\,000)。

每个测试用例的接下来 ⌈log⁡2(n+1)⌉\lceil\log_2 (n + 1) \rceil 行按接收顺序包含传输的数据。每行由 nn 个字符组成,每个字符为 00 或 11。

附加输入约束:

  • 所有测试用例的 nn 值之和不超过 2 0002\,000。

输出格式

For each test case, print one integer — the answer to the problem.

对于每个测试用例,输出一个整数——即该问题的答案。

输入输出样例

  • 输入#1

    6
    1
    1
    4
    1010
    0001
    0110
    7
    0101011
    1100101
    0110110
    5
    10110
    01100
    11001
    6
    001011
    111000
    000000
    7
    1100001
    1100001
    1100011

    输出#1

    1
    2
    6
    0
    0
    0

说明/提示

In the first example, there could be only one permutation, p=[1]p = [1].

In the second example, there are 22 possible variants: [1,2,3,4][1, 2, 3, 4] and [2,1,3,4][2, 1, 3, 4].

In the fourth example, there are no suitable original permutations.

在第一个例子中,只可能存在一种排列:p=[1]p = [1]。

在第二个例子中,存在 22 种可能的排列:[1,2,3,4][1, 2, 3, 4] 和 [2,1,3,4][2, 1, 3, 4]。

在第四个例子中,不存在满足条件的原始排列。

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

首页