結果
| 問題 | No.1689 Set Cards |
| コンテスト | |
| ユーザー |
tenten
|
| 提出日時 | 2021-11-09 14:36:03 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
AC
|
| 実行時間 | 698 ms / 2,000 ms |
| コード長 | 1,616 bytes |
| 記録 | |
| コンパイル時間 | 1,940 ms |
| コンパイル使用メモリ | 84,032 KB |
| 実行使用メモリ | 54,000 KB |
| 最終ジャッジ日時 | 2026-05-13 00:25:00 |
| 合計ジャッジ時間 | 6,584 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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();
}
}
tenten