結果
問題 |
No.1689 Set Cards
|
ユーザー |
![]() |
提出日時 | 2021-11-09 14:36:03 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 747 ms / 2,000 ms |
コード長 | 1,616 bytes |
コンパイル時間 | 2,266 ms |
コンパイル使用メモリ | 79,116 KB |
実行使用メモリ | 62,548 KB |
最終ジャッジ日時 | 2024-11-18 12:35:01 |
合計ジャッジ時間 | 7,228 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
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(); } }