結果

問題 No.411 昇順昇順ソート
ユーザー beetbeet
提出日時 2020-12-03 16:59:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,282 ms / 2,000 ms
コード長 496 bytes
コンパイル時間 1,971 ms
コンパイル使用メモリ 197,932 KB
実行使用メモリ 331,208 KB
最終ジャッジ日時 2023-10-12 02:51:42
合計ジャッジ時間 12,713 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 200 ms
331,180 KB
testcase_01 AC 194 ms
331,180 KB
testcase_02 AC 195 ms
331,052 KB
testcase_03 AC 206 ms
331,048 KB
testcase_04 AC 182 ms
330,976 KB
testcase_05 AC 184 ms
331,044 KB
testcase_06 AC 183 ms
331,032 KB
testcase_07 AC 181 ms
331,096 KB
testcase_08 AC 181 ms
331,208 KB
testcase_09 AC 178 ms
331,136 KB
testcase_10 AC 176 ms
331,072 KB
testcase_11 AC 177 ms
331,036 KB
testcase_12 AC 177 ms
331,036 KB
testcase_13 AC 177 ms
331,044 KB
testcase_14 AC 176 ms
331,036 KB
testcase_15 AC 177 ms
331,080 KB
testcase_16 AC 177 ms
331,120 KB
testcase_17 AC 176 ms
331,072 KB
testcase_18 AC 175 ms
331,184 KB
testcase_19 AC 176 ms
330,972 KB
testcase_20 AC 175 ms
331,140 KB
testcase_21 AC 179 ms
330,980 KB
testcase_22 AC 176 ms
330,976 KB
testcase_23 AC 176 ms
330,952 KB
testcase_24 AC 176 ms
330,976 KB
testcase_25 AC 177 ms
330,952 KB
testcase_26 AC 176 ms
331,044 KB
testcase_27 AC 182 ms
331,072 KB
testcase_28 AC 1,282 ms
331,032 KB
testcase_29 AC 530 ms
330,952 KB
testcase_30 AC 463 ms
330,976 KB
testcase_31 AC 434 ms
331,124 KB
testcase_32 AC 247 ms
331,180 KB
testcase_33 AC 230 ms
330,948 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