結果
問題 | No.1958 Bit Game |
ユーザー | nephrologist |
提出日時 | 2022-05-27 22:08:41 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 473 ms / 2,000 ms |
コード長 | 1,227 bytes |
コンパイル時間 | 300 ms |
コンパイル使用メモリ | 81,736 KB |
実行使用メモリ | 121,712 KB |
最終ジャッジ日時 | 2023-10-20 20:20:01 |
合計ジャッジ時間 | 12,571 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 472 ms
121,708 KB |
testcase_01 | AC | 473 ms
121,708 KB |
testcase_02 | AC | 469 ms
121,708 KB |
testcase_03 | AC | 466 ms
121,712 KB |
testcase_04 | AC | 471 ms
121,704 KB |
testcase_05 | AC | 466 ms
121,708 KB |
testcase_06 | AC | 469 ms
121,708 KB |
testcase_07 | AC | 468 ms
121,712 KB |
testcase_08 | AC | 467 ms
121,708 KB |
testcase_09 | AC | 466 ms
121,712 KB |
testcase_10 | AC | 155 ms
88,004 KB |
testcase_11 | AC | 249 ms
107,204 KB |
testcase_12 | AC | 296 ms
111,656 KB |
testcase_13 | AC | 286 ms
113,380 KB |
testcase_14 | AC | 263 ms
106,928 KB |
testcase_15 | AC | 311 ms
117,292 KB |
testcase_16 | AC | 221 ms
111,844 KB |
testcase_17 | AC | 400 ms
117,244 KB |
testcase_18 | AC | 377 ms
118,448 KB |
testcase_19 | AC | 260 ms
119,548 KB |
testcase_20 | AC | 293 ms
107,096 KB |
testcase_21 | AC | 331 ms
118,216 KB |
testcase_22 | AC | 174 ms
88,256 KB |
testcase_23 | AC | 192 ms
100,020 KB |
testcase_24 | AC | 367 ms
113,404 KB |
testcase_25 | AC | 212 ms
102,956 KB |
testcase_26 | AC | 282 ms
108,180 KB |
testcase_27 | AC | 287 ms
116,088 KB |
testcase_28 | AC | 330 ms
117,904 KB |
testcase_29 | AC | 199 ms
97,112 KB |
testcase_30 | AC | 37 ms
53,584 KB |
testcase_31 | AC | 37 ms
53,584 KB |
testcase_32 | AC | 47 ms
61,928 KB |
ソースコード
import sys input = sys.stdin.buffer.readline n, x, y = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) cntA = [0] * (20) cntB = [0] * 20 for i in range(x): for num in range(20): if (A[i] >> num) & 1: cntA[num] += 1 for i in range(y): for num in range(20): if (B[i] >> num) & 1: cntB[num] += 1 # print("x", x, file=sys.stderr) # print("y", y, file=sys.stderr) # print(cntA, file=sys.stderr) # print(cntB, file=sys.stderr) ans = 0 mod = 998244353 def calc(p0, p1, a, b, c, d): r0 = 0 r1 = 0 r0 += p0 * a % mod r1 += (p0 * b % mod + p1 * (a + b)) % mod r0, r1 = (r0 * (c + d) % mod + r1 * c % mod) % mod, r1 * d % mod return r0, r1 ans = 0 for i in range(20): xx = cntA[i] xxx = x - xx yy = cntB[i] yyy = y - yy t0, t1 = 1, 0 for _ in range(n): # print("hoge", t0, t1, xxx, xx, yyy, yy, file=sys.stderr) t0, t1 = calc(t0, t1, xxx, xx, yyy, yy) # print("t1", t1, file=sys.stderr) # print("keisu", 1 << i, file=sys.stderr) ans += (t1 * (1 << i)) % mod # print("ans", ans, file=sys.stderr) ans %= mod # ans = pow(ans, n, mod) print(ans)