A15851 | Count Voting
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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$ .
$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.
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)$ .
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)$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted