結果

問題 No.2159 Filling 4x4 array
ユーザー vwxyzvwxyz
提出日時 2023-02-16 07:47:02
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 862 bytes
コンパイル時間 482 ms
コンパイル使用メモリ 86,520 KB
実行使用メモリ 84,992 KB
最終ジャッジ日時 2023-09-25 13:31:29
合計ジャッジ時間 12,294 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 464 ms
78,392 KB
testcase_01 AC 312 ms
78,364 KB
testcase_02 AC 2,868 ms
79,344 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline=sys.stdin.readline
from functools import lru_cache

HW=list(map(int,readline().split()))
for i in range(8):
    HW[i]-=4
H,W=HW[:4],HW[4:]
mod=998244353
@lru_cache(maxsize=None)
def solve(H,W):
    for h in H:
        if h<0:
            return 0
    for w in W:
        if w<0:
            return 0
    if all(h==0 for h in H) and all(w==0 for w in W):
        return 1
    retu=0
    for bit in range(1<<16):
        HH=[H[h]-sum(bit>>h*4+w&1 for w in range(4)) for h in range(4)]
        WW=[W[w]-sum(bit>>h*4+w&1 for h in range(4)) for w in range(4)]
        if all(h>=0 and h%2==0 for h in HH) and all(w>=0 and w%2==0 for w in WW):
            for i in range(4):
                HH[i]>>=1
                WW[i]>>=1
            retu+=solve(tuple(HH),tuple(WW))
            retu%=mod
    return retu
ans=solve(tuple(H),tuple(W))
print(ans)
0