这怕是假题
先看一看题解做法
根据题意……显然每个水果是否能够进到最终选择的盘子里是相互独立的……
设$p_i$表示第$i$个水果最终被选到了,$cnt_i$表示第$i$个水果在多少个盘子中出现了
则有
$$1-p_i=\frac{n - cnt_i \choose k}{{n \choose k}}$$
即没有被选中的方案数相当于去掉这个水果后剩余盘子中拿出$k$个盘子的方案
之后答案就显得十分显然……$ans=\sum_{i=1}^{m}p_ia_i + (1-p_i)b_i$……
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
1 %:pragma GCC optimize(2) 2 %:pragma GCC optimize(3) 3 %:pragma GCC optimize("Ofast") 4 %:pragma GCC optimize("inline") 5 %:pragma GCC optimize("-fgcse") 6 %:pragma GCC optimize("-fgcse-lm") 7 %:pragma GCC optimize("-fipa-sra") 8 %:pragma GCC optimize("-ftree-pre") 9 %:pragma GCC optimize("-ftree-vrp") 10 %:pragma GCC optimize("-fpeephole2") 11 %:pragma GCC optimize("-ffast-math") 12 %:pragma GCC optimize("-fsched-spec") 13 %:pragma GCC optimize("unroll-loops") 14 %:pragma GCC optimize("-falign-jumps") 15 %:pragma GCC optimize("-falign-loops") 16 %:pragma GCC optimize("-falign-labels") 17 %:pragma GCC optimize("-fdevirtualize") 18 %:pragma GCC optimize("-fcaller-saves") 19 %:pragma GCC optimize("-fcrossjumping") 20 %:pragma GCC optimize("-fthread-jumps") 21 %:pragma GCC optimize("-funroll-loops") 22 %:pragma GCC optimize("-fwhole-program") 23 %:pragma GCC optimize("-freorder-blocks") 24 %:pragma GCC optimize("-fschedule-insns") 25 %:pragma GCC optimize("inline-functions") 26 %:pragma GCC optimize("-ftree-tail-merge") 27 %:pragma GCC optimize("-fschedule-insns2") 28 %:pragma GCC optimize("-fstrict-aliasing") 29 %:pragma GCC optimize("-fstrict-overflow") 30 %:pragma GCC optimize("-falign-functions") 31 %:pragma GCC optimize("-fcse-skip-blocks") 32 %:pragma GCC optimize("-fcse-follow-jumps") 33 %:pragma GCC optimize("-fsched-interblock") 34 %:pragma GCC optimize("-fpartial-inlining") 35 %:pragma GCC optimize("no-stack-protector") 36 %:pragma GCC optimize("-freorder-functions") 37 %:pragma GCC optimize("-findirect-inlining") 38 %:pragma GCC optimize("-fhoist-adjacent-loads") 39 %:pragma GCC optimize("-frerun-cse-after-loop") 40 %:pragma GCC optimize("inline-small-functions") 41 %:pragma GCC optimize("-finline-small-functions") 42 %:pragma GCC optimize("-ftree-switch-conversion") 43 %:pragma GCC optimize("-foptimize-sibling-calls") 44 %:pragma GCC optimize("-fexpensive-optimizations") 45 %:pragma GCC optimize("-funsafe-loop-optimizations") 46 %:pragma GCC optimize("inline-functions-called-once") 47 %:pragma GCC optimize("-fdelete-null-pointer-checks") 48 49 #include <bits/stdc++.h> 50 using namespace std; 51 typedef long long ll; 52 const int N = 1e5 + 10, mod = 998244353; 53 ll ans, fac[N], inv[N]; 54 int n, m, k, a[N], b[N], cnt[N]; 55 ll pw(ll a, ll b) { 56 ll r = 1; 57 for( ; b ; b >>= 1, a = a * a % mod) if(b & 1) r = r * a % mod; 58 return r; 59 } 60 61 ll C(ll n, ll m) { 62 if(m > n) return 0; 63 return fac[n] * inv[m] % mod * inv[n - m] % mod; 64 } 65 66 int main() { 67 freopen("eat.in", "r", stdin); 68 freopen("eat.out", "w", stdout); 69 scanf("%d%d%d", &n, &m, &k); 70 fac[0] = inv[0] = 1; 71 for(int i = 1 ; i <= n ; ++ i) fac[i] = fac[i - 1] * i % mod; 72 for(int i = 1 ; i <= n ; ++ i) inv[i] = pw(fac[i], mod - 2); 73 for(int i = 1 ; i <= m ; ++ i) scanf("%d", &a[i]); 74 for(int i = 1 ; i <= m ; ++ i) scanf("%d", &b[i]); 75 for(int i = 1, k ; i <= n ; ++ i) { 76 scanf("%d", &k); 77 for(int j = 1, x ; j <= k ; ++ j) { 78 scanf("%d", &x); 79 ++ cnt[x]; 80 } 81 } 82 for(int i = 1 ; i <= m ; ++ i) { 83 ll nop = C(n - cnt[i], k) * pw(C(n, k), mod - 2) % mod; 84 ll p = (1 - nop) % mod; 85 ans = (ans + p * a[i] % mod) % mod; 86 ans = (ans + nop * b[i] % mod) % mod; 87 } 88 ans = (ans % mod + mod) % mod; 89 printf("%lld\n", ans); 90 }