結果

問題 No.1689 Set Cards
ユーザー merlinmerlin
提出日時 2021-09-24 22:27:15
言語 Java19
(openjdk 21)
結果
AC  
実行時間 176 ms / 2,000 ms
コード長 1,180 bytes
コンパイル時間 3,813 ms
コンパイル使用メモリ 73,312 KB
実行使用メモリ 54,884 KB
最終ジャッジ日時 2023-09-18 21:44:04
合計ジャッジ時間 7,474 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,192 KB
testcase_01 AC 44 ms
49,080 KB
testcase_02 AC 52 ms
50,276 KB
testcase_03 AC 49 ms
50,232 KB
testcase_04 AC 51 ms
49,960 KB
testcase_05 AC 50 ms
49,980 KB
testcase_06 AC 49 ms
49,924 KB
testcase_07 AC 45 ms
49,112 KB
testcase_08 AC 43 ms
49,412 KB
testcase_09 AC 43 ms
49,444 KB
testcase_10 AC 47 ms
49,892 KB
testcase_11 AC 125 ms
52,568 KB
testcase_12 AC 126 ms
52,648 KB
testcase_13 AC 129 ms
53,008 KB
testcase_14 AC 160 ms
54,388 KB
testcase_15 AC 101 ms
52,840 KB
testcase_16 AC 120 ms
53,016 KB
testcase_17 AC 87 ms
52,520 KB
testcase_18 AC 130 ms
52,940 KB
testcase_19 AC 167 ms
54,884 KB
testcase_20 AC 169 ms
54,632 KB
testcase_21 AC 134 ms
52,784 KB
testcase_22 AC 130 ms
53,368 KB
testcase_23 AC 131 ms
53,388 KB
testcase_24 AC 176 ms
54,632 KB
testcase_25 AC 127 ms
53,380 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;
        /*ArrayList<Integer> g[]=new ArrayList[m];
        for(i=0;i<m;i++) g[i]=new ArrayList<>();
        for(i=0;i<m;i++)
        for(j=0;j<m;j++)
        if(j!=i && (i|j)==(i^j)) g[i].add(j);*/

        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