結果

問題 No.1689 Set Cards
ユーザー merlinmerlin
提出日時 2021-09-24 23:50:11
言語 Java21
(openjdk 21)
結果
AC  
実行時間 181 ms / 2,000 ms
コード長 990 bytes
コンパイル時間 2,878 ms
コンパイル使用メモリ 74,632 KB
実行使用メモリ 55,308 KB
最終ジャッジ日時 2023-09-18 22:29:08
合計ジャッジ時間 6,591 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
49,312 KB
testcase_01 AC 45 ms
47,440 KB
testcase_02 AC 56 ms
50,232 KB
testcase_03 AC 52 ms
50,020 KB
testcase_04 AC 51 ms
50,196 KB
testcase_05 AC 52 ms
50,036 KB
testcase_06 AC 52 ms
50,456 KB
testcase_07 AC 48 ms
49,432 KB
testcase_08 AC 46 ms
49,724 KB
testcase_09 AC 46 ms
49,472 KB
testcase_10 AC 49 ms
50,128 KB
testcase_11 AC 164 ms
54,760 KB
testcase_12 AC 165 ms
55,308 KB
testcase_13 AC 132 ms
52,808 KB
testcase_14 AC 132 ms
53,388 KB
testcase_15 AC 103 ms
51,276 KB
testcase_16 AC 123 ms
52,872 KB
testcase_17 AC 89 ms
52,716 KB
testcase_18 AC 132 ms
53,980 KB
testcase_19 AC 179 ms
54,740 KB
testcase_20 AC 181 ms
54,588 KB
testcase_21 AC 132 ms
54,900 KB
testcase_22 AC 137 ms
53,296 KB
testcase_23 AC 138 ms
53,424 KB
testcase_24 AC 179 ms
55,144 KB
testcase_25 AC 142 ms
52,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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]);
    }
}
0