結果
| 問題 |
No.411 昇順昇順ソート
|
| コンテスト | |
| ユーザー |
nCk_cv
|
| 提出日時 | 2016-08-28 01:05:31 |
| 言語 | Java (openjdk 23) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 798 bytes |
| コンパイル時間 | 2,283 ms |
| コンパイル使用メモリ | 77,216 KB |
| 実行使用メモリ | 46,720 KB |
| 最終ジャッジ日時 | 2024-11-08 20:10:20 |
| 合計ジャッジ時間 | 10,247 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 24 TLE * 1 -- * 5 |
ソースコード
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;
}
}
nCk_cv