結果

問題 No.1689 Set Cards
ユーザー tentententen
提出日時 2021-11-09 14:36:03
言語 Java21
(openjdk 21)
結果
AC  
実行時間 820 ms / 2,000 ms
コード長 1,616 bytes
コンパイル時間 2,714 ms
コンパイル使用メモリ 78,776 KB
実行使用メモリ 50,680 KB
最終ジャッジ日時 2024-04-29 09:59:34
合計ジャッジ時間 7,895 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
36,872 KB
testcase_01 AC 52 ms
36,628 KB
testcase_02 AC 56 ms
36,764 KB
testcase_03 AC 59 ms
36,932 KB
testcase_04 AC 61 ms
36,704 KB
testcase_05 AC 58 ms
36,904 KB
testcase_06 AC 54 ms
36,988 KB
testcase_07 AC 54 ms
36,704 KB
testcase_08 AC 52 ms
36,652 KB
testcase_09 AC 51 ms
36,832 KB
testcase_10 AC 53 ms
36,948 KB
testcase_11 AC 451 ms
45,040 KB
testcase_12 AC 418 ms
44,768 KB
testcase_13 AC 123 ms
39,632 KB
testcase_14 AC 244 ms
48,296 KB
testcase_15 AC 180 ms
44,296 KB
testcase_16 AC 207 ms
44,372 KB
testcase_17 AC 130 ms
40,940 KB
testcase_18 AC 463 ms
45,012 KB
testcase_19 AC 95 ms
38,796 KB
testcase_20 AC 104 ms
38,712 KB
testcase_21 AC 59 ms
37,016 KB
testcase_22 AC 78 ms
37,752 KB
testcase_23 AC 92 ms
38,740 KB
testcase_24 AC 820 ms
45,520 KB
testcase_25 AC 360 ms
50,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Main {
    static final int MOD = 998244353;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        TreeMap<Integer, Integer> current = new TreeMap<>();
        current.put((1 << 12) - 1, 1);
        for (int i = 0; i < n; i++) {
            int count = sc.nextInt();
            int x = 0;
            for (int j = 0; j < count; j++) {
                x += (1 << (sc.nextInt() - 1));
            }
            Integer key = -1;
            while ((key = current.higherKey(key)) != null) {
                int next = (key & x);
                current.put(next, (current.getOrDefault(next, 0) + current.get(key)) % MOD);
            }
        }
        System.out.println(current.getOrDefault(0, 0));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public String nextLine() throws Exception {
        return br.readLine();
    }
    
    public String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0