시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
4 초 | 512 MB | 15 | 10 | 9 | 75.000% |
Professor JOI is a leading expert on the study of the history of IOI Kingdom. When he was surveying an old temple in IOI Kingdom, he found ruins where the stone pillars were constructed. He also found an old document which was supposedly written by ancient people in IOI Kingdom. The document contains descriptions on the stone pillars. More precisely, the following is written in the document.
Professor JOI thinks it would be a great discovery if he can recover the heights of the 2N stone pillars when they were constructed. He surveyed the place where the stone pillars were constructed in more detail. He found that, after the N earthquakes occurred, the indices of the remaining stone pillars were A1, A2, . . . , AN.
Professor JOI wants to know the number of possible combinations of the heights of the 2N stone pillars when they were constructed. Since you are a pupil of Professor JOI, you are asked to write a program which counts this number.
Write a program which, given the indices of the remaining stone pillars after the N earthquakes occurred, calculates the number of possible combinations of the heights of the 2N stone pillars when they were constructed, modulo 1 000 000 007.
Read the following data from the standard input. All the values in the input are integers.
N A1 · · · AN
Write one line to the standard output. Output the remainder when the answer is divided by 1 000 000 007.
번호 | 배점 | 제한 |
---|---|---|
1 | 6 | N ≤ 13. |
2 | 52 | N ≤ 60. |
3 | 42 | No additional constraints. |
3 3 4 6
5
For example, assume that the heights of the stone pillars were (2, 2, 3, 3, 1, 1), from the stone pillar 1. Since there were exactly two stone pillars of height k for each k (1 ≤ k ≤ 3), it agrees with the description in the old document.
After the three earthquakes, the stone pillars 3, 4, 6 remained. It coincides with the information given in the input.
In addition to the above, there are four possible combinations of the heights of the stone pillars (2, 3, 2, 3, 1, 1), (2, 3, 3, 2, 1, 1), (3, 2, 2, 3, 1, 1), (3, 2, 3, 2, 1, 1).
Therefore, there are five possible combinations of the heights of the six stone pillars which agree with the description in the old document and the information given in the input.
1 1
0
In this sample input, (1, 1) is the only combination of the heights of the stone pillars which agrees with the description in the old document. After the first earthquake, the heights of the stone pillars became (0, 1).
Therefore, there is no possible combination of the heights of the stone pillars which agrees with the description in the old document and the information given in the input.
10 5 8 9 13 15 16 17 18 19 20
147003663
There are 111 147 004 440 possible combinations of the heights of the 2N stone pillars, when they were constructed. When 111 147 004 440 is divided by 1 000 000 007, the remainder is 147 003 663. Thus, output 147 003 663.