結果

問題 No.1958 Bit Game
ユーザー 👑 rin204rin204
提出日時 2022-05-27 21:30:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 285 ms / 2,000 ms
コード長 1,255 bytes
コンパイル時間 637 ms
コンパイル使用メモリ 81,584 KB
実行使用メモリ 143,232 KB
最終ジャッジ日時 2023-10-20 19:54:49
合計ジャッジ時間 8,950 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 282 ms
142,964 KB
testcase_01 AC 274 ms
142,968 KB
testcase_02 AC 285 ms
142,964 KB
testcase_03 AC 285 ms
142,968 KB
testcase_04 AC 278 ms
142,980 KB
testcase_05 AC 277 ms
142,964 KB
testcase_06 AC 277 ms
143,232 KB
testcase_07 AC 281 ms
142,964 KB
testcase_08 AC 278 ms
142,964 KB
testcase_09 AC 282 ms
142,964 KB
testcase_10 AC 109 ms
89,100 KB
testcase_11 AC 165 ms
105,904 KB
testcase_12 AC 194 ms
108,308 KB
testcase_13 AC 176 ms
105,000 KB
testcase_14 AC 162 ms
104,140 KB
testcase_15 AC 211 ms
109,780 KB
testcase_16 AC 172 ms
103,512 KB
testcase_17 AC 235 ms
113,728 KB
testcase_18 AC 231 ms
114,124 KB
testcase_19 AC 183 ms
110,752 KB
testcase_20 AC 161 ms
103,368 KB
testcase_21 AC 222 ms
114,228 KB
testcase_22 AC 107 ms
89,208 KB
testcase_23 AC 141 ms
101,364 KB
testcase_24 AC 220 ms
113,732 KB
testcase_25 AC 145 ms
104,568 KB
testcase_26 AC 164 ms
107,928 KB
testcase_27 AC 198 ms
106,164 KB
testcase_28 AC 185 ms
103,976 KB
testcase_29 AC 127 ms
98,680 KB
testcase_30 AC 37 ms
53,376 KB
testcase_31 AC 36 ms
53,376 KB
testcase_32 AC 41 ms
59,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353

def matpow(A, B, w):
    l = len(A)
    while w:
        if w & 1:
            C = [0] * l
            for i in range(l):
                for j in range(l):
                    C[i] += A[i][j] * B[j]
                    C[i] %= MOD
            B = C
        C = [[0] * l for _ in range(l)]
        for i in range(l):
            for j in range(l):
                for k in range(l):
                    C[i][j] += A[i][k] * A[k][j]
                    C[i][j] %= MOD
        A = C
        w >>= 1
    return B

n, x, y = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
for i in range(18):
    ac = [0, 0]
    for a in A:
        if a >> i & 1:
            ac[1] += 1
        else:
            ac[0] += 1
    bc = [0, 0]
    for b in B:
        if b >> i & 1:
            bc[1] += 1
        else:
            bc[0] += 1

    B_ = [1, 0]
    A_ = [[0, 0], [0, 0]]
    A_[0][0] += ac[0] * bc[0]
    A_[0][0] += ac[0] * bc[1]
    A_[0][0] += ac[1] * bc[0]
    A_[1][0] += ac[1] * bc[1]
    A_[0][1] += ac[0] * bc[0]
    A_[1][1] += ac[0] * bc[1]
    A_[0][1] += ac[1] * bc[0]
    A_[1][1] += ac[1] * bc[1]
    ret = matpow(A_, B_, n)
    ans += ret[1] << i
    ans %= MOD
print(ans)
0