結果

問題 No.2082 AND OR XOR
ユーザー 👑 tamatotamato
提出日時 2022-09-25 22:25:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,590 ms / 2,000 ms
コード長 1,306 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 87,020 KB
実行使用メモリ 80,184 KB
最終ジャッジ日時 2023-08-24 02:21:32
合計ジャッジ時間 32,525 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
76,368 KB
testcase_01 AC 97 ms
76,296 KB
testcase_02 AC 130 ms
76,876 KB
testcase_03 AC 1,350 ms
78,960 KB
testcase_04 AC 478 ms
77,472 KB
testcase_05 AC 846 ms
78,436 KB
testcase_06 AC 1,166 ms
78,612 KB
testcase_07 AC 922 ms
78,472 KB
testcase_08 AC 675 ms
78,244 KB
testcase_09 AC 418 ms
77,644 KB
testcase_10 AC 926 ms
78,320 KB
testcase_11 AC 681 ms
78,040 KB
testcase_12 AC 1,580 ms
79,596 KB
testcase_13 AC 758 ms
77,960 KB
testcase_14 AC 665 ms
77,700 KB
testcase_15 AC 969 ms
78,380 KB
testcase_16 AC 1,286 ms
78,944 KB
testcase_17 AC 1,061 ms
78,612 KB
testcase_18 AC 315 ms
77,096 KB
testcase_19 AC 1,267 ms
79,548 KB
testcase_20 AC 821 ms
78,076 KB
testcase_21 AC 1,093 ms
78,788 KB
testcase_22 AC 922 ms
78,356 KB
testcase_23 AC 1,401 ms
79,280 KB
testcase_24 AC 1,369 ms
79,048 KB
testcase_25 AC 1,439 ms
79,352 KB
testcase_26 AC 570 ms
77,680 KB
testcase_27 AC 772 ms
78,092 KB
testcase_28 AC 1,578 ms
79,368 KB
testcase_29 AC 1,584 ms
80,184 KB
testcase_30 AC 1,590 ms
79,452 KB
testcase_31 AC 1,586 ms
79,716 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353


def main():
    import sys
    input = sys.stdin.readline

    N, a, b, c = map(int, input().split())
    Z = [[0] * 4 for _ in range(4)]
    for x in range(4):
        for y in range(4):
            Z[x][y] = (a * (x & y) + b * (x | y) + c * (x ^ y)) % 4

    ans = 0
    dp = [[0] * 256 for _ in range(4)]
    for i in range(4):
        state = 0
        for j in range(4):
            r = Z[i][j]
            state += r << (2 * j)
        dp[i][state] += 1
    for t in range(N - 1):
        dp_new = [[0] * 256 for _ in range(4)]
        for l in range(4):
            for state in range(256):
                A = []
                s = state
                for _ in range(4):
                    A.append(s % 4)
                    s >>= 2
                for x in range(4):
                    l_new = Z[l][x]
                    state_new = 0
                    for j in range(4):
                        r = A[Z[j][x]]
                        state_new += r << (2 * j)
                    dp_new[l_new][state_new] = (dp_new[l_new][state_new] + dp[l][state]) % mod
                    if t == N - 2:
                        if l_new == A[x]:
                            ans = (ans + dp[l][state]) % mod
        dp = dp_new

    print(ans)


if __name__ == '__main__':
    main()
0