CF1799G.Count Voting
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There are n people that will participate in voting. Each person has exactly one vote.
i -th person has a team ti ( 1≤ti≤n ) where ti=tj 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 ci 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 998244353 .
输入格式
The first line contains a single integer n ( 1≤n≤200 ) — the number of people.
The second line contains n integers c1,c2,…,cn ( 0≤ci≤n ) — desired number of votes. It is guaranteed, that i=1∑nci=n .
The third line contains n integers t1,t2,…,tn ( 1≤ti≤n ) — team numbers.
输出格式
Print a single integer — the number of possible votings by modulo 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
说明/提示
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) .