QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 512 MB Total points: 100

#5658. Problem Setting

統計

Note: The memory limit for this problem is 512MB, twice the default.

Farmer John created $N$ ($1\le N\le 10^5$) problems. He then recruited $M$ ($1\le M\le 20$) test-solvers, each of which rated every problem as "easy" or "hard."

His goal is now to create a problemset arranged in increasing order of difficulty, consisting of some subset of his $N$ problems arranged in some order. There must exist no pair of problems such that some test-solver thinks the problem later in the order is easy but the problem earlier in the order is hard.

Count the number of distinct nonempty problemsets he can form, modulo $10^9+7$.

INPUT FORMAT (input arrives from the terminal / stdin):

The first line contains $N$ and $M$.

The next $M$ lines each contain a string of length $N$. The $i$th character of this string is E if the test-solver thinks the $i$th problem is easy, or H otherwise.

OUTPUT FORMAT (print output to the terminal / stdout):

The number of distinct problemsets FJ can form, modulo $10^9+7$.

SAMPLE INPUT:

3 1
EHE

SAMPLE OUTPUT:

9
The nine possible problemsets are as follows:
[1]
[1,2]
[1,3]
[1,3,2]
[2]
[3]
[3,1]
[3,2]
[3,1,2]
Note that the order of the problems within the problemset matters.

SAMPLE INPUT:

10 6
EHEEEHHEEH
EHHHEEHHHE
EHEHEHEEHH
HEHEEEHEEE
HHEEHEEEHE
EHHEEEEEHE

SAMPLE OUTPUT:

33

SCORING:

  • Inputs 3-4: $M=1$
  • Inputs 5-14: $M\le 16$
  • Inputs 15-22: No additional constraints.

Problem credits: Benjamin Qi

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.