結果

問題 No.411 昇順昇順ソート
ユーザー uafr_csuafr_cs
提出日時 2016-08-12 23:07:56
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 876 bytes
コンパイル時間 2,075 ms
コンパイル使用メモリ 77,228 KB
実行使用メモリ 49,432 KB
最終ジャッジ日時 2024-04-25 05:40:36
合計ジャッジ時間 7,283 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
40,296 KB
testcase_01 AC 122 ms
41,248 KB
testcase_02 AC 110 ms
40,040 KB
testcase_03 AC 119 ms
40,912 KB
testcase_04 AC 126 ms
41,200 KB
testcase_05 AC 128 ms
41,300 KB
testcase_06 AC 123 ms
40,808 KB
testcase_07 AC 124 ms
41,032 KB
testcase_08 AC 125 ms
41,012 KB
testcase_09 AC 114 ms
40,188 KB
testcase_10 AC 123 ms
41,044 KB
testcase_11 AC 121 ms
41,088 KB
testcase_12 AC 112 ms
40,176 KB
testcase_13 AC 111 ms
40,068 KB
testcase_14 AC 125 ms
41,144 KB
testcase_15 AC 114 ms
39,944 KB
testcase_16 AC 112 ms
39,844 KB
testcase_17 AC 120 ms
39,948 KB
testcase_18 AC 120 ms
41,468 KB
testcase_19 AC 125 ms
41,316 KB
testcase_20 AC 127 ms
41,144 KB
testcase_21 AC 114 ms
39,832 KB
testcase_22 AC 115 ms
39,828 KB
testcase_23 AC 116 ms
39,868 KB
testcase_24 WA -
testcase_25 AC 122 ms
40,148 KB
testcase_26 AC 124 ms
41,472 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 141 ms
45,468 KB
testcase_30 AC 136 ms
49,052 KB
testcase_31 AC 132 ms
49,432 KB
testcase_32 AC 138 ms
49,196 KB
testcase_33 AC 134 ms
48,708 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
	
	public static long dfs(long[] memo, final int N, final int bit, final int K){
		if(memo[bit] >= 0){
			return memo[bit];
		}
		
		//System.out.println(Integer.toBinaryString(bit));
		
		final int all_bit_up = (1 << (K + 1)) - 1;
		if(all_bit_up == bit){ return memo[bit] = 0; }
		
		memo[bit] = 1;
		for(int k = K + 1; k < N; k++){
			if((bit & (1 << k)) != 0){ continue; }
			
			memo[bit] += dfs(memo, N, bit | (1 << k), k);
		}
		
		return memo[bit];
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		final int K = sc.nextInt() - 1;
		
		long[] memo = new long[1 << N];
		Arrays.fill(memo, -1);
		
		System.out.println(dfs(memo, N, 1 << K, K));
	}

}
0