#P3230. [HNOI2013] 比赛

    ID: 2279 远端评测题 2000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>搜索2013湖南深度优先搜索,DFS哈希,HASH

[HNOI2013] 比赛

Description

Momo loves watching soccer matches, but she missed the latest league because she was addicted to an archery game. There are NN teams in the league, and the rules are as follows:

  1. Every pair of teams plays exactly one match.
  2. If a match ends in a draw, each team gets 11 point.
  3. Otherwise, the winner gets 33 points and the loser gets 00 points.

Although she could not watch the exciting matches, Momo learned from the news the final total points of each team. Now she wants to compute how many possible tournament outcomes are consistent with these totals.

For example, if there are 33 teams and each team finishes with 33 points, then there are two possibilities:

Possibility 11 and Possibility 22

Team AA BB CC Points Team AA BB CC Points
AA - 33 00 33 AA - 00 33 33
BB 00 - 33 BB 33 - 00
CC 33 00 - CC 00 33 -

Since the answer can be large, output it modulo 109+710^9+7.

Input Format

The first line contains a positive integer NN, the number of teams.
The second line contains NN non-negative integers, giving the final total points of each team in order.

Output Format

Output a single integer, the answer modulo 109+710^9+7.

4
4 3 6 4
3

Hint

  • 20%20\% of the testdata satisfies N4N \le 4.
  • 40%40\% of the testdata satisfies N6N \le 6.
  • 60%60\% of the testdata satisfies N8N \le 8.
  • 100%100\% of the testdata satisfies 3N103 \le N \le 10, and there exists at least one solution.

Translated by ChatGPT 5