|
| 1 | +```java |
| 2 | + |
| 3 | +import java.util.*; |
| 4 | +import java.io.*; |
| 5 | + |
| 6 | + |
| 7 | +class Main { |
| 8 | + |
| 9 | + // IO field |
| 10 | + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); |
| 11 | + static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); |
| 12 | + static StringTokenizer st; |
| 13 | + |
| 14 | + static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());} |
| 15 | + static int nextInt() {return Integer.parseInt(st.nextToken());} |
| 16 | + static long nextLong() {return Long.parseLong(st.nextToken());} |
| 17 | + static void bwEnd() throws Exception {bw.flush();bw.close();} |
| 18 | + |
| 19 | + // Additional field |
| 20 | + |
| 21 | + static long[] C = new long[1000001]; |
| 22 | + static long[] ans; |
| 23 | + static List<Integer> A = new ArrayList<>(); |
| 24 | + static int N; |
| 25 | + static long[] F = new long[1000001]; |
| 26 | + |
| 27 | + static final long mod = 998244353; |
| 28 | + |
| 29 | + public static void main(String[] args) throws Exception { |
| 30 | + |
| 31 | + ready(); |
| 32 | + solve(); |
| 33 | + |
| 34 | + bwEnd(); |
| 35 | + |
| 36 | + } |
| 37 | + |
| 38 | + static void ready() throws Exception{ |
| 39 | + |
| 40 | + |
| 41 | + N = Integer.parseInt(br.readLine()); |
| 42 | + for(int p=0;p<N;p++) { |
| 43 | + nextLine(); |
| 44 | + for(int i=nextInt();i-->0;) A.add(nextInt()); |
| 45 | + } |
| 46 | + Collections.sort(A); |
| 47 | + for(int i=0;i<A.size();) { |
| 48 | + int cnt = 0, a = A.get(i); |
| 49 | + while(i<A.size() && A.get(i).equals(a)) { |
| 50 | + cnt++; |
| 51 | + i++; |
| 52 | + } |
| 53 | + C[cnt]++; |
| 54 | + } |
| 55 | + |
| 56 | + ans = new long[N+1]; |
| 57 | + |
| 58 | + F[0] = 1; |
| 59 | + for(int i=1;i<=N;i++) F[i] = (F[i-1] * i) % mod; |
| 60 | + |
| 61 | + } |
| 62 | + |
| 63 | + static void solve() throws Exception{ |
| 64 | + |
| 65 | + for(int i=1;i<=N;i++) if(C[i] > 0) { |
| 66 | + for(int k=1;k<=i;k++) { |
| 67 | + ans[k] = (ans[k] + C[i] * comb(i, k)) % mod; |
| 68 | + } |
| 69 | + } |
| 70 | + |
| 71 | + for(int i=1;i<=N;i++) bw.write(ans[i] + "\n"); |
| 72 | + |
| 73 | + } |
| 74 | + |
| 75 | + static long comb(int n, int k) { |
| 76 | + return F[n] * power(F[k],mod-2) % mod * power(F[n-k],mod-2) % mod; |
| 77 | + } |
| 78 | + |
| 79 | + static long power(long n, long m) { |
| 80 | + if(m == 0) return 1; |
| 81 | + if(m == 1) return n; |
| 82 | + long p = power(n,m>>1) % mod; |
| 83 | + p = (p*p) % mod; |
| 84 | + if(m%2 == 0) return p; |
| 85 | + return p*n%mod; |
| 86 | + } |
| 87 | + |
| 88 | +} |
| 89 | + |
| 90 | +``` |
0 commit comments