結果

問題 No.1631 Sorting Integers (Multiple of K) Easy
ユーザー たたき@競プロたたき@競プロ
提出日時 2023-08-31 05:41:18
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 812 bytes
コンパイル時間 5,998 ms
コンパイル使用メモリ 309,340 KB
実行使用メモリ 259,980 KB
最終ジャッジ日時 2023-08-31 05:41:57
合計ジャッジ時間 38,811 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 WA -
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 7 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 WA -
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 4 ms
4,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 1,970 ms
247,636 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2,072 ms
259,672 KB
testcase_21 AC 1,810 ms
228,416 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 2,027 ms
255,044 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using mint=modint998244353; //1000000007;
using ll=long long;
using pp=pair<int,int>;
#define sr string 
#define vc vector
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define pque priority_queue
#define bpc(a) __builtin_popcount(a)
int main(){
  ll n,k;cin>>n>>k;
  vc<ll>v;
  for(ll i=1;i<10;i++){
    ll a;cin>>a;
    rep(j,a)v.pb(i);
  }
  vc<ll>ten(n); ten[0]=1; rep(i,n-1)ten[i+1]=ten[i]*10;
  vc dp(1<<n,vc<ll>(k,0)); dp[0][0]=1;
  rep(i,n){
    vc pre(1<<n,vc<ll>(k,0)); swap(pre,dp);
    rep(j,1<<n)if(bpc(j)==i)rep(t,k){
      rep(x,n)if(~j>>x&1)dp[j|1<<x][(t+v[i]*ten[x])%k]+=pre[j][t];
    }
  }
  cout<<dp[(1<<n)-1][0];
}
0