結果
問題 | No.1631 Sorting Integers (Multiple of K) Easy |
ユーザー | mlasdf2 |
提出日時 | 2021-08-01 11:37:29 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2,140 ms / 3,000 ms |
コード長 | 2,690 bytes |
コンパイル時間 | 6,625 ms |
コンパイル使用メモリ | 230,128 KB |
実行使用メモリ | 131,300 KB |
最終ジャッジ日時 | 2023-10-14 18:44:01 |
合計ジャッジ時間 | 30,373 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,368 KB |
testcase_01 | AC | 2 ms
4,372 KB |
testcase_02 | AC | 1 ms
4,368 KB |
testcase_03 | AC | 8 ms
4,368 KB |
testcase_04 | AC | 2 ms
4,368 KB |
testcase_05 | AC | 2 ms
4,372 KB |
testcase_06 | AC | 1 ms
4,372 KB |
testcase_07 | AC | 2 ms
4,368 KB |
testcase_08 | AC | 2 ms
4,372 KB |
testcase_09 | AC | 9 ms
4,368 KB |
testcase_10 | AC | 2 ms
4,372 KB |
testcase_11 | AC | 4 ms
4,372 KB |
testcase_12 | AC | 3 ms
4,368 KB |
testcase_13 | AC | 2 ms
4,372 KB |
testcase_14 | AC | 2,039 ms
125,364 KB |
testcase_15 | AC | 2,137 ms
131,020 KB |
testcase_16 | AC | 2,135 ms
131,060 KB |
testcase_17 | AC | 2,136 ms
131,060 KB |
testcase_18 | AC | 2,136 ms
131,300 KB |
testcase_19 | AC | 2,140 ms
131,196 KB |
testcase_20 | AC | 793 ms
131,128 KB |
testcase_21 | AC | 1,015 ms
115,620 KB |
testcase_22 | AC | 954 ms
129,020 KB |
testcase_23 | AC | 1,295 ms
128,892 KB |
testcase_24 | AC | 1,126 ms
129,052 KB |
testcase_25 | AC | 1,085 ms
127,676 KB |
testcase_26 | AC | 7 ms
4,368 KB |
testcase_27 | AC | 1,410 ms
95,396 KB |
testcase_28 | AC | 593 ms
41,900 KB |
testcase_29 | AC | 501 ms
42,580 KB |
testcase_30 | AC | 855 ms
61,236 KB |
testcase_31 | AC | 1,338 ms
94,896 KB |
ソースコード
#include<bits/stdc++.h> using namespace std; #include<atcoder/all> using namespace atcoder; typedef long long ll; const long long INF = 1LL<<60; const double PI = acos(-1.0); /*const double PI = atan2(0.0,-1.0)*/ template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } #define rep(i, n) for(ll i = 0; i < (ll)(n); i++) #define rep1(i,aa,n) for(ll i = aa; i <= (ll)(n); i++) #define ALL(a) (a).begin(),(a).end() #define v2d(val1,val2,ini) vector<vector<ll>>(val1,vector<ll>(val2,ini)); #define v3d(val1,val2,val3,ini) vector<vector<vector<ll>>>(val1,vector<vector<ll>>(val2,vector<ll>(val3,ini))); #define v4d(val1,val2,val3,val4,ini) vector<vector<vector<vector<ll>>>>(val1,vector<vector<vector<ll>>>(val2,vector<<vector<ll>>(val3,vector<ll>(val4,ini)))); #define pqe priority_queue<ll> #define pqeg priority_queue<ll,vector<ll>,greater<ll>> #define lcin(...) ll __VA_ARGS__;CINT(__VA_ARGS__) #define eout(...) COU(__VA_ARGS__); #define sout(...) SCOU(__VA_ARGS__); #define scin(...) string __VA_ARGS__;CINT(__VA_ARGS__) #define lb(aa,val) lower_bound(ALL(aa),val) #define pb push_back #define bpc __builtin_popcountll ll kaijou(ll e){ll r=1;rep(i,e){r*=(i+1);}return r;} bool kukan(ll t,ll a,ll b){ if(a<=t&&t<=b){ return true; }else return false; } void CINT(){} template <class Head,class... Tail> void CINT(Head&& head,Tail&&... tail){ cin>>head; CINT(move(tail)...); } void COU(){} template <class Head,class... Tail> void COU(Head&& head,Tail&&... tail){ cout<<head<<endl; COU(move(tail)...); } void SCOU(){} template <class Head,class... Tail> void SCOU(Head&& head,Tail&&... tail){ cout<<head<<" "; SCOU(move(tail)...); } template <class T = ll> T IN(){T x;cin>>x;return (x);} using pii = pair<ll,ll>; using v2 = vector<vector<ll>>; using v1 = vector<ll>; using v2p = vector<vector<pii>>; using v1p = vector<pii>; const ll mo=1000000007; //const ll mo=998244353; ll mod_pow(ll N,ll n){ if(n==0) return 1; ll hh; hh=n%2; int tt=mod_pow(N,n/2); if(hh==0)return tt%mo*tt%mo; else {return tt%mo*tt%mo*N%mo;} } int main(){ //cout<<fixed<<setprecision(15); lcin(n,K); v1 aa(10,0); v1 bb(n,0); ll ichi=0; rep1(i,1,9){ lcin(a); aa[i]=a; rep(k,a){ bb[ichi]=i; ichi++; } } auto dp=v2d(1<<n,K,0); dp[0][0]=1; v1 keta(n,0); keta[0]=1; rep(i,n){ if(i){ keta[i]=keta[i-1]*10; keta[i]%=K; } } rep(tmp,1<<n){ if(tmp==0)continue; v1 gg(11,0); ll pp=bpc(tmp); rep(i,n){ if((tmp&1<<i)&&!gg[bb[i]]){ gg[bb[i]]=1; rep(k,K){ dp[tmp][k]+=dp[tmp^(1<<i)][(k-(keta[pp-1]*bb[i])%K+K)%K]; } } } } eout(dp[(1<<n)-1][0]); }