結果
問題 |
No.1631 Sorting Integers (Multiple of K) Easy
|
ユーザー |
![]() |
提出日時 | 2023-08-31 05:41:18 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 812 bytes |
コンパイル時間 | 6,969 ms |
コンパイル使用メモリ | 332,380 KB |
実行使用メモリ | 260,052 KB |
最終ジャッジ日時 | 2025-01-03 04:26:20 |
合計ジャッジ時間 | 40,174 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 WA * 1 |
other | AC * 9 WA * 19 |
ソースコード
#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]; }