結果

問題 No.663 セルオートマトンの逆操作
ユーザー convexineqconvexineq
提出日時 2021-03-02 21:20:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 528 bytes
コンパイル時間 365 ms
コンパイル使用メモリ 82,140 KB
実行使用メモリ 74,912 KB
最終ジャッジ日時 2024-04-14 04:58:45
合計ジャッジ時間 3,343 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,280 KB
testcase_01 AC 39 ms
52,756 KB
testcase_02 AC 40 ms
52,284 KB
testcase_03 AC 40 ms
52,356 KB
testcase_04 AC 39 ms
53,152 KB
testcase_05 AC 38 ms
52,680 KB
testcase_06 AC 38 ms
52,552 KB
testcase_07 AC 38 ms
52,360 KB
testcase_08 AC 40 ms
52,564 KB
testcase_09 AC 40 ms
52,004 KB
testcase_10 AC 39 ms
53,048 KB
testcase_11 AC 40 ms
54,144 KB
testcase_12 AC 38 ms
52,328 KB
testcase_13 AC 39 ms
53,428 KB
testcase_14 AC 39 ms
52,732 KB
testcase_15 AC 39 ms
52,936 KB
testcase_16 AC 47 ms
60,284 KB
testcase_17 AC 40 ms
52,132 KB
testcase_18 AC 44 ms
54,112 KB
testcase_19 AC 42 ms
53,488 KB
testcase_20 AC 50 ms
62,300 KB
testcase_21 AC 67 ms
70,988 KB
testcase_22 AC 72 ms
73,296 KB
testcase_23 AC 73 ms
73,116 KB
testcase_24 AC 76 ms
74,572 KB
testcase_25 AC 74 ms
73,900 KB
testcase_26 AC 75 ms
74,912 KB
testcase_27 AC 45 ms
53,572 KB
testcase_28 AC 41 ms
53,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,*a = map(int,open(0).read().split())
MOD = 10**9+7
ans = 0
nxt = [0,1,1,1,0,1,1,0]
for x in range(4):
    dp = [0]*4
    dp[x] = 1
    for i in range(1,n-1):
        ndp = [0]*4
        for j in range(4):
            for k in range(2):
                if a[i] == nxt[j*2+k]:
                    nj = (j*2+k)%4
                    ndp[nj] += dp[j]
                    ndp[nj] %= MOD
        dp = ndp    
    for y in range(4):
        if nxt[y%2*4+x] == a[0] and nxt[y*2+x//2] == a[n-1]:
            ans += dp[y]
print(ans%MOD)
0