結果
問題 | No.1631 Sorting Integers (Multiple of K) Easy |
ユーザー | とりゐ |
提出日時 | 2021-07-08 15:35:01 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 713 bytes |
コンパイル時間 | 355 ms |
コンパイル使用メモリ | 86,816 KB |
実行使用メモリ | 206,748 KB |
最終ジャッジ日時 | 2023-10-14 02:11:48 |
合計ジャッジ時間 | 27,322 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | AC | 71 ms
71,260 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 72 ms
71,368 KB |
testcase_06 | WA | - |
testcase_07 | AC | 73 ms
71,300 KB |
testcase_08 | AC | 72 ms
71,272 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 76 ms
75,768 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 2,361 ms
200,528 KB |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 408 ms
206,128 KB |
testcase_21 | RE | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | AC | 1,454 ms
204,024 KB |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
ソースコード
import itertools n,p=map(int,input().split()) a=list(map(int,input().split())) c1=[0]*9 for i in a: c1[i-1]+=1 c2=[] for i in range(9): c2.append([c1[i],i]) c2.sort(reverse=True) q=[1]*n for i in range(1,n): q[i]=(q[i-1]*10)%p d=set([0]) memo=[[0]*p for i in range(2**n)] memo[0][0]=1 for a in range(9): i=c2[a][1] if c1[i]==0: continue e=set() for j in d: t=[] for k in range(n): if (j>>k)&1==0: t.append(k) all=itertools.combinations(t,c1[i]) for x in all: y=j cnt=0 for k in x: cnt+=q[k] y+=2**k for k in range(p): s=(cnt*(i+1)+k)%p memo[y][s]+=memo[j][k] e.add(y) d=e.copy() print(memo[2**n-1][0])