結果
問題 |
No.1689 Set Cards
|
ユーザー |
![]() |
提出日時 | 2021-09-24 23:50:11 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 192 ms / 2,000 ms |
コード長 | 990 bytes |
コンパイル時間 | 2,587 ms |
コンパイル使用メモリ | 77,192 KB |
実行使用メモリ | 41,392 KB |
最終ジャッジ日時 | 2024-07-05 11:38:36 |
合計ジャッジ時間 | 6,205 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
import java.io.*; import java.util.*; class Main { public static void main(String args[])throws Exception { BufferedReader bu=new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb=new StringBuilder(); int t=12,i,j,m=1<<t; int n=Integer.parseInt(bu.readLine()); long dp[][]=new long[2][m],M=998244353; dp[0][m-1]=1; int cur=1; for(i=1;i<=n;i++) { for(j=0;j<m;j++) dp[cur][j]=dp[cur^1][j]; String s[]=bu.readLine().split(" "); int k=Integer.parseInt(s[0]),x,vis=0; for(j=0;j<k;j++) { x=Integer.parseInt(s[j+1])-1; vis|=1<<x; } for(j=0;j<m;j++) dp[cur][j&vis]=(dp[cur][j&vis]+dp[cur^1][j])%M; cur^=1; //for(j=0;j<10;j++) System.out.print(dp[cur^1][j]+" "); //System.out.println(); } System.out.println(dp[cur^1][0]); } }