当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6001:Mr.Panda and Survey

题目描述
Mr.Panda did a survey among N candidates.
In the survey, each candidate was given a questionnaire which contains M yes/no questions. It is guaranteed that each question was answered with a “Yes” or a “No” by each candidate.
Mr.Panda likes variety. He considers a question as a good question if there are at least one candidate answered “Yes” and at least one candidate answered “No” for that question.
Now Mr.Panda has collected all the questionnaires. He wants to do some statistical analysis based on the survey result.
Because Mr.Panda is super lazy, he wants to randomly pick some of the questionnaires as a sample.
For each possible subset of questions (excluding empty set), Mr.Panda wants to know the probability that all questions in the subset are good questions, assuming that questionnaires in the sample are chosen randomly so that sample can be any subset (including full set and empty set) of questionnaires with equal probability.
Could you help Mr.Panda solve this problem?
To simplify the problem, you are only required to calculate ( $P_1 · 2^N$ mod 1000000007) ⊕ ( $P_2 · 2^N$ mod 1000000007) ⊕ · · · ⊕ ( $P_{2^M-1}$· $2^N$ mod 1000000007)
where $P_i$ means the probability of i th subset of questions to be good questions. It is obvious that $P_i · 2^N$ is always an integer.
“⊕” which is known as “bitwise exclusive or” corresponds to operator “^”in both C/C++ and Java.
“ mod ” which is known as “modulo” corresponds to operator “%” in both C/C++ and Java.
输入解释
The first line of the input gives the number of test cases, T.
T test cases follow. Each test case consists of two lines. The first line contains two integers N, the number of questionnaires, and M, the number of questions.
The second line contains N strings $Q_1, Q_2, ... , Q_N$ representing the answers in each questionnaire.
Each questionnaire $Q_i$ is given in the form of exact M charecters where each character can be either “Y” standing for “Yes” or “N” standing for “No”.
输出解释
For each test case, output one line containing “Case #x: y”, where x is the test case number(starting from 1) and y is the xor sum of the weighted probabilities.

limits


$\bullet 1 ≤ T ≤ 20.$
$\bullet 1 ≤ N ≤ 10^5.$
$\bullet 1 ≤ M ≤ 15.$
输入样例
2
2 2
NY YN
4 2
NN NY YN YY
输出样例
Case #1: 1
Case #2: 7
提示
来自杭电HDUOJ的附加信息
Recommend jiangzijing2015

该题目是Virtual Judge题目,来自 杭电HDUOJ

题目来源 2016 CCPC-Final

源链接: HDU-6001

最后修改于 2020-10-25T23:27:25+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
60000/30000MS(Java/Others) 100000/100000K(Java/Others)