結果

問題 No.411 昇順昇順ソート
ユーザー imulanimulan
提出日時 2016-08-13 00:13:16
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,100 ms / 2,000 ms
コード長 829 bytes
コンパイル時間 2,394 ms
コンパイル使用メモリ 164,772 KB
実行使用メモリ 331,340 KB
最終ジャッジ日時 2023-08-07 12:07:22
合計ジャッジ時間 8,338 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 154 ms
331,028 KB
testcase_01 AC 89 ms
331,044 KB
testcase_02 AC 85 ms
331,024 KB
testcase_03 AC 84 ms
331,028 KB
testcase_04 AC 84 ms
331,028 KB
testcase_05 AC 85 ms
331,080 KB
testcase_06 AC 84 ms
331,084 KB
testcase_07 AC 85 ms
331,144 KB
testcase_08 AC 84 ms
331,024 KB
testcase_09 AC 85 ms
331,068 KB
testcase_10 AC 86 ms
331,068 KB
testcase_11 AC 85 ms
331,140 KB
testcase_12 AC 85 ms
331,096 KB
testcase_13 AC 85 ms
331,096 KB
testcase_14 AC 85 ms
331,096 KB
testcase_15 AC 85 ms
331,032 KB
testcase_16 AC 85 ms
331,036 KB
testcase_17 AC 85 ms
331,204 KB
testcase_18 AC 85 ms
331,156 KB
testcase_19 AC 84 ms
331,040 KB
testcase_20 AC 84 ms
331,212 KB
testcase_21 AC 85 ms
331,292 KB
testcase_22 AC 86 ms
331,024 KB
testcase_23 AC 84 ms
331,028 KB
testcase_24 AC 85 ms
331,028 KB
testcase_25 AC 85 ms
331,204 KB
testcase_26 AC 85 ms
331,076 KB
testcase_27 AC 90 ms
331,032 KB
testcase_28 AC 1,100 ms
331,064 KB
testcase_29 AC 469 ms
331,028 KB
testcase_30 AC 509 ms
331,036 KB
testcase_31 AC 476 ms
331,340 KB
testcase_32 AC 166 ms
331,036 KB
testcase_33 AC 140 ms
331,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int n,k;
ll dp[1<<20][20][2];

ll dfs(int mask, int prev, int big)
{
    if(dp[mask][prev][big]>=0) return dp[mask][prev][big];
    if(mask == (1<<n)-1) return big;


    ll ret=0;

    rep(i,n)
    {
        if(mask>>i&1) continue;

        if(i>prev) ret+=dfs(mask+(1<<i), i, big);
        else
        {
            if(big==0) ret+=dfs(mask+(1<<i), i, 1);
        }
    }

    return dp[mask][prev][big]=ret;
}

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