結果

問題 No.1689 Set Cards
ユーザー ks2mks2m
提出日時 2021-09-24 22:53:08
言語 Java19
(openjdk 21)
結果
AC  
実行時間 311 ms / 2,000 ms
コード長 705 bytes
コンパイル時間 2,197 ms
コンパイル使用メモリ 74,276 KB
実行使用メモリ 61,764 KB
最終ジャッジ日時 2023-09-18 21:57:21
合計ジャッジ時間 9,055 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,868 KB
testcase_01 AC 123 ms
55,472 KB
testcase_02 AC 148 ms
58,240 KB
testcase_03 AC 151 ms
56,032 KB
testcase_04 AC 149 ms
56,036 KB
testcase_05 AC 148 ms
56,432 KB
testcase_06 AC 145 ms
55,912 KB
testcase_07 AC 131 ms
55,608 KB
testcase_08 AC 120 ms
56,016 KB
testcase_09 AC 120 ms
55,328 KB
testcase_10 AC 125 ms
55,728 KB
testcase_11 AC 297 ms
59,668 KB
testcase_12 AC 300 ms
59,796 KB
testcase_13 AC 255 ms
59,632 KB
testcase_14 AC 287 ms
60,160 KB
testcase_15 AC 215 ms
59,536 KB
testcase_16 AC 269 ms
60,000 KB
testcase_17 AC 203 ms
59,084 KB
testcase_18 AC 292 ms
59,880 KB
testcase_19 AC 311 ms
61,764 KB
testcase_20 AC 305 ms
59,808 KB
testcase_21 AC 215 ms
59,092 KB
testcase_22 AC 241 ms
59,000 KB
testcase_23 AC 246 ms
58,660 KB
testcase_24 AC 311 ms
59,904 KB
testcase_25 AC 304 ms
59,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] k = new int[n];
		int[] c = new int[n];
		for (int i = 0; i < n; i++) {
			k[i] = sc.nextInt();
			for (int j = 0; j < k[i]; j++) {
				c[i] += 1 << (sc.nextInt() - 1);
			}
		}
		sc.close();

		int mod = 998244353;
		int m = 1 << 12;
		long[] dp = new long[m];
		for (int i = 0; i < n; i++) {
			long[] wk = new long[m];
			for (int j = 0; j < m; j++) {
				wk[j] += dp[j];
				wk[j & c[i]] += dp[j];
			}
			wk[c[i]]++;
			for (int j = 0; j < m; j++) {
				wk[j] %= mod;
			}
			dp = wk;
		}
		System.out.println(dp[0]);
	}
}
0