結果

問題 No.462 6日知らずのコンピュータ
ユーザー uafr_csuafr_cs
提出日時 2017-11-11 07:12:57
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,136 bytes
コンパイル時間 2,142 ms
コンパイル使用メモリ 77,420 KB
実行使用メモリ 56,460 KB
最終ジャッジ日時 2024-05-03 15:56:37
合計ジャッジ時間 16,261 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
54,260 KB
testcase_01 AC 130 ms
54,008 KB
testcase_02 WA -
testcase_03 AC 137 ms
54,280 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 132 ms
53,860 KB
testcase_09 AC 132 ms
54,360 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 130 ms
54,144 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 132 ms
54,208 KB
testcase_29 WA -
testcase_30 AC 131 ms
54,124 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 130 ms
54,472 KB
testcase_34 WA -
testcase_35 AC 135 ms
54,376 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 134 ms
53,900 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 133 ms
54,104 KB
testcase_45 AC 127 ms
54,112 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 131 ms
54,124 KB
testcase_50 AC 133 ms
54,368 KB
testcase_51 AC 131 ms
54,360 KB
testcase_52 AC 139 ms
54,252 KB
testcase_53 AC 131 ms
54,328 KB
testcase_54 AC 132 ms
54,000 KB
testcase_55 AC 133 ms
54,224 KB
testcase_56 AC 139 ms
54,368 KB
testcase_57 AC 136 ms
54,156 KB
testcase_58 AC 134 ms
54,232 KB
testcase_59 AC 137 ms
54,528 KB
testcase_60 AC 135 ms
54,224 KB
testcase_61 AC 131 ms
54,312 KB
testcase_62 WA -
testcase_63 AC 134 ms
54,144 KB
testcase_64 AC 127 ms
54,544 KB
testcase_65 AC 128 ms
54,080 KB
testcase_66 AC 137 ms
54,316 KB
testcase_67 AC 139 ms
54,472 KB
testcase_68 AC 137 ms
54,280 KB
testcase_69 AC 136 ms
54,364 KB
testcase_70 AC 132 ms
53,944 KB
testcase_71 AC 136 ms
54,300 KB
testcase_72 AC 131 ms
54,272 KB
testcase_73 AC 133 ms
54,276 KB
testcase_74 AC 130 ms
54,324 KB
testcase_75 AC 138 ms
54,340 KB
testcase_76 AC 131 ms
54,464 KB
testcase_77 AC 135 ms
54,060 KB
testcase_78 AC 139 ms
54,300 KB
testcase_79 AC 131 ms
53,984 KB
testcase_80 AC 129 ms
54,044 KB
testcase_81 AC 116 ms
53,224 KB
testcase_82 AC 131 ms
54,376 KB
testcase_83 AC 134 ms
54,208 KB
testcase_84 AC 129 ms
54,104 KB
testcase_85 AC 129 ms
54,312 KB
testcase_86 AC 130 ms
54,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	
	public static long MOD = 1000000007;
	
	public static long fact(long N){
		long ret = 1;
		for(long i = 1; i <= N; i++){ 
			ret *= i;
			ret %= MOD;
		}
		return ret;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		final int k = sc.nextInt();
		
		// k = 0 の時は N bit なので N! 個の立て方がある 
		if(k == 0){
			System.out.println(fact(N));
			return;
		}
		
		// k >= 1 の時は
		// ソートするとトポロジカル順序になると思っていた
		long[] as = new long[k + 1];
		for(int i = 0; i < k; i++){
			as[i] = sc.nextLong();
		}
		as[k] =(1 << N) - 1;
		
		//*
		Arrays.sort(as);
		
		for(int i = 1; i < k; i++){
			if((as[i] & as[i - 1]) != as[i - 1]){
				System.out.println(0);
				return;
			}
		}
		
		long answer = fact(Long.bitCount(as[0]));
		for(int i = 1; i < k; i++){
			final long xor = as[i] ^ as[i - 1];
			answer *= fact(Long.bitCount(xor));
			answer %= MOD;
		}
		
		System.out.println(answer);
		//*/
	}
}
0