310205: CF1799G. Count Voting

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Count Voting

题意翻译

$n$ 个人,每人可以给任意一个人投一票,但是不能投给同组的人(包括自己)。第 $i$ 个人属于第 $t_i$ 组,希望得到 $c_i$ 票,求使得每个人都满足愿望的投票方案数,模 $998244353$。 $\sum_{i=1}^nc_i=n,\space\space1\le t_i\le n,\space\space0\le c_i\le n,\space\space1\le n\le200$。

题目描述

There are $ n $ people that will participate in voting. Each person has exactly one vote. $ i $ -th person has a team $ t_i $ ( $ 1 \leq t_i \leq n $ ) where $ t_i = t_j $ means $ i $ , $ j $ are in the same team. By the rules each person should vote for the person from the different team. Note that it automatically means that each person can't vote for himself. Each person knows the number of votes $ c_i $ he wants to get. How many possible votings exists, such that each person will get the desired number of votes? Due to this number can be big, find it by modulo $ 998\,244\,353 $ .

输入输出格式

输入格式


The first line contains a single integer $ n $ ( $ 1 \leq n \leq 200 $ ) — the number of people. The second line contains $ n $ integers $ c_1, c_2, \ldots, c_n $ ( $ 0 \leq c_i \leq n $ ) — desired number of votes. It is guaranteed, that $ \sum\limits_{i=1}^{n} c_i = n $ . The third line contains $ n $ integers $ t_1, t_2, \ldots, t_n $ ( $ 1 \leq t_i \leq n $ ) — team numbers.

输出格式


Print a single integer — the number of possible votings by modulo $ 998\,244\,353 $ .

输入输出样例

输入样例 #1

3
1 1 1
1 2 3

输出样例 #1

2

输入样例 #2

5
2 0 1 0 2
1 2 3 4 5

输出样例 #2

10

输入样例 #3

5
1 2 2 0 0
3 5 4 3 4

输出样例 #3

5

说明

In the first test there are two possible votings: $ (2, 3, 1) $ , $ (3, 1, 2) $ . In the third test there are five possible votings: $ (3, 3, 2, 2, 1) $ , $ (2, 3, 2, 3, 1) $ , $ (3, 3, 1, 2, 2) $ , $ (3, 1, 2, 3, 2) $ , $ (2, 3, 1, 3, 2) $ .

Input

题意翻译

$n$ 个人,每人可以给任意一个人投一票,但是不能投给同组的人(包括自己)。第 $i$ 个人属于第 $t_i$ 组,希望得到 $c_i$ 票,求使得每个人都满足愿望的投票方案数,模 $998244353$。 $\sum_{i=1}^nc_i=n,\space\space1\le t_i\le n,\space\space0\le c_i\le n,\space\space1\le n\le200$。

Output

**投票计数**

**题目大意:**
有 $ n $ 个人参与投票,每人有一票。第 $ i $ 个人属于第 $ t_i $ 组,$ t_i = t_j $ 表示 $ i $ 和 $ j $ 在同一组,每组内的人不能相互投票,也不能投给自己。每个人希望得到 $ c_i $ 票,求满足每个人愿望的投票方案数,结果对 $ 998244353 $ 取模。已知 $\sum_{i=1}^nc_i=n$,$ 1\le t_i\le n $,$ 0\le c_i\le n $,$ 1\le n\le200 $。

**输入输出格式:**
- **输入格式:**
- 第一行一个整数 $ n $($ 1 \leq n \leq 200 $)表示人数。
- 第二行 $ n $ 个整数 $ c_1, c_2, \ldots, c_n $($ 0 \leq c_i \leq n $)表示每个人希望得到的票数,保证 $\sum_{i=1}^{n} c_i = n $。
- 第三行 $ n $ 个整数 $ t_1, t_2, \ldots, t_n $($ 1 \leq t_i \leq n $)表示每个人所在的组。
- **输出格式:**
- 输出一个整数,表示可能的投票方案数对 $ 998244353 $ 取模的结果。

**输入输出样例:**
- **输入样例 #1**
```
3
1 1 1
1 2 3
```
- **输出样例 #1**
```
2
```
- **输入样例 #2**
```
5
2 0 1 0 2
1 2 3 4 5
```
- **输出样例 #2**
```
10
```
- **输入样例 #3**
```
5
1 2 2 0 0
3 5 4 3 4
```
- **输出样例 #3**
```
5
```**投票计数** **题目大意:** 有 $ n $ 个人参与投票,每人有一票。第 $ i $ 个人属于第 $ t_i $ 组,$ t_i = t_j $ 表示 $ i $ 和 $ j $ 在同一组,每组内的人不能相互投票,也不能投给自己。每个人希望得到 $ c_i $ 票,求满足每个人愿望的投票方案数,结果对 $ 998244353 $ 取模。已知 $\sum_{i=1}^nc_i=n$,$ 1\le t_i\le n $,$ 0\le c_i\le n $,$ 1\le n\le200 $。 **输入输出格式:** - **输入格式:** - 第一行一个整数 $ n $($ 1 \leq n \leq 200 $)表示人数。 - 第二行 $ n $ 个整数 $ c_1, c_2, \ldots, c_n $($ 0 \leq c_i \leq n $)表示每个人希望得到的票数,保证 $\sum_{i=1}^{n} c_i = n $。 - 第三行 $ n $ 个整数 $ t_1, t_2, \ldots, t_n $($ 1 \leq t_i \leq n $)表示每个人所在的组。 - **输出格式:** - 输出一个整数,表示可能的投票方案数对 $ 998244353 $ 取模的结果。 **输入输出样例:** - **输入样例 #1** ``` 3 1 1 1 1 2 3 ``` - **输出样例 #1** ``` 2 ``` - **输入样例 #2** ``` 5 2 0 1 0 2 1 2 3 4 5 ``` - **输出样例 #2** ``` 10 ``` - **输入样例 #3** ``` 5 1 2 2 0 0 3 5 4 3 4 ``` - **输出样例 #3** ``` 5 ```

加入题单

算法标签: