結果

問題 No.411 昇順昇順ソート
ユーザー beetbeet
提出日時 2018-07-30 14:10:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,153 ms / 2,000 ms
コード長 496 bytes
コンパイル時間 1,441 ms
コンパイル使用メモリ 165,228 KB
実行使用メモリ 331,340 KB
最終ジャッジ日時 2023-10-11 20:37:22
合計ジャッジ時間 7,783 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
331,028 KB
testcase_01 AC 86 ms
330,984 KB
testcase_02 AC 86 ms
331,080 KB
testcase_03 AC 85 ms
330,984 KB
testcase_04 AC 86 ms
330,984 KB
testcase_05 AC 85 ms
331,036 KB
testcase_06 AC 85 ms
331,040 KB
testcase_07 AC 85 ms
331,040 KB
testcase_08 AC 85 ms
330,972 KB
testcase_09 AC 85 ms
331,076 KB
testcase_10 AC 85 ms
330,984 KB
testcase_11 AC 85 ms
331,140 KB
testcase_12 AC 85 ms
331,020 KB
testcase_13 AC 85 ms
331,024 KB
testcase_14 AC 85 ms
331,020 KB
testcase_15 AC 84 ms
330,976 KB
testcase_16 AC 84 ms
331,228 KB
testcase_17 AC 85 ms
331,040 KB
testcase_18 AC 85 ms
330,988 KB
testcase_19 AC 87 ms
331,032 KB
testcase_20 AC 85 ms
331,076 KB
testcase_21 AC 86 ms
331,036 KB
testcase_22 AC 86 ms
331,040 KB
testcase_23 AC 85 ms
331,040 KB
testcase_24 AC 84 ms
331,072 KB
testcase_25 AC 85 ms
331,144 KB
testcase_26 AC 86 ms
331,020 KB
testcase_27 AC 91 ms
330,980 KB
testcase_28 AC 1,153 ms
331,084 KB
testcase_29 AC 430 ms
331,340 KB
testcase_30 AC 367 ms
330,992 KB
testcase_31 AC 340 ms
330,984 KB
testcase_32 AC 151 ms
331,064 KB
testcase_33 AC 133 ms
331,080 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
Int n,k;
Int dp[2][20][1<<20];
int dfs(Int f,Int p,Int b){
  Int &res=dp[f][p][b];
  if(~res) return res;
  if(b+1==(1<<n)) return f;
  res=0;
  for(Int i=0;i<n;i++){
    if((b>>i)&1) continue;
    Int nf=p>i,nb=b|(1<<i);
    if(nf&&f) continue;
    nf|=f;
    res+=dfs(nf,i,nb);
  }
  return res;
};

signed main(){
  cin>>n>>k;
  memset(dp,-1,sizeof(dp));
  k--;
  cout<<dfs(0,k,1<<k)<<endl;
  return 0;
}
0