結果

問題 No.411 昇順昇順ソート
ユーザー imulanimulan
提出日時 2016-08-13 00:13:16
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,182 ms / 2,000 ms
コード長 829 bytes
コンパイル時間 1,458 ms
コンパイル使用メモリ 162,160 KB
実行使用メモリ 331,392 KB
最終ジャッジ日時 2024-04-25 05:57:37
合計ジャッジ時間 13,051 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 234 ms
331,264 KB
testcase_01 AC 243 ms
331,136 KB
testcase_02 AC 240 ms
331,264 KB
testcase_03 AC 233 ms
331,136 KB
testcase_04 AC 233 ms
331,264 KB
testcase_05 AC 231 ms
331,136 KB
testcase_06 AC 235 ms
331,264 KB
testcase_07 AC 234 ms
331,136 KB
testcase_08 AC 236 ms
331,136 KB
testcase_09 AC 237 ms
331,136 KB
testcase_10 AC 238 ms
331,136 KB
testcase_11 AC 233 ms
331,264 KB
testcase_12 AC 234 ms
331,264 KB
testcase_13 AC 236 ms
331,136 KB
testcase_14 AC 246 ms
331,136 KB
testcase_15 AC 233 ms
331,136 KB
testcase_16 AC 233 ms
331,264 KB
testcase_17 AC 233 ms
331,264 KB
testcase_18 AC 242 ms
331,264 KB
testcase_19 AC 235 ms
331,136 KB
testcase_20 AC 232 ms
331,136 KB
testcase_21 AC 232 ms
331,136 KB
testcase_22 AC 236 ms
331,136 KB
testcase_23 AC 233 ms
331,264 KB
testcase_24 AC 240 ms
331,264 KB
testcase_25 AC 229 ms
331,136 KB
testcase_26 AC 237 ms
331,392 KB
testcase_27 AC 245 ms
331,264 KB
testcase_28 AC 1,182 ms
331,136 KB
testcase_29 AC 604 ms
331,264 KB
testcase_30 AC 636 ms
331,136 KB
testcase_31 AC 618 ms
331,136 KB
testcase_32 AC 322 ms
331,136 KB
testcase_33 AC 293 ms
331,264 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