結果

問題 No.411 昇順昇順ソート
ユーザー nCk_cvnCk_cv
提出日時 2016-08-28 01:05:31
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 798 bytes
コンパイル時間 2,424 ms
コンパイル使用メモリ 77,676 KB
実行使用メモリ 61,092 KB
最終ジャッジ日時 2024-04-26 07:11:26
合計ジャッジ時間 9,513 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
61,092 KB
testcase_01 AC 125 ms
54,608 KB
testcase_02 AC 137 ms
54,016 KB
testcase_03 AC 123 ms
54,316 KB
testcase_04 AC 119 ms
54,324 KB
testcase_05 AC 124 ms
54,044 KB
testcase_06 AC 123 ms
53,888 KB
testcase_07 AC 123 ms
54,252 KB
testcase_08 AC 122 ms
54,088 KB
testcase_09 AC 125 ms
53,968 KB
testcase_10 AC 125 ms
54,152 KB
testcase_11 AC 110 ms
52,968 KB
testcase_12 AC 122 ms
53,904 KB
testcase_13 AC 123 ms
54,020 KB
testcase_14 AC 122 ms
54,068 KB
testcase_15 AC 123 ms
54,200 KB
testcase_16 AC 124 ms
53,864 KB
testcase_17 AC 123 ms
54,160 KB
testcase_18 AC 124 ms
54,152 KB
testcase_19 AC 112 ms
52,952 KB
testcase_20 AC 121 ms
54,108 KB
testcase_21 AC 110 ms
52,720 KB
testcase_22 AC 125 ms
54,276 KB
testcase_23 AC 111 ms
53,100 KB
testcase_24 AC 136 ms
54,040 KB
testcase_25 AC 124 ms
53,568 KB
testcase_26 AC 123 ms
54,352 KB
testcase_27 AC 260 ms
53,508 KB
testcase_28 TLE -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
public class Main {
		static int INF = 2 << 27;
		public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			int K = sc.nextInt();
			int ans = dfs(0,K,new int[N],new boolean[N],false);
			System.out.println(ans);
		}
		static int dfs(int a, int b, int[] c, boolean[] d, boolean e) {
			if(a == 0) {
				c[a] = b;
				d[b-1] = true;
				return dfs(a+1,b,c,d,e);
			}
			if(a == c.length) {
				if(e)
				return 1;
				return 0;
			}
			int ret = 0;
			for(int i = 0; i < c.length; i++) {
				if(d[i]) continue;
				boolean nex = e;
				if(c[a-1] > i+1) {
					if(e) continue;
					nex = true;
				}
				c[a] = i+1;
				d[i] = true;
				ret += dfs(a+1,b,c,d,nex);
				c[a] = 0;
				d[i] = false;
			}
			return ret;
		}

}
0