結果

問題 No.1068 #いろいろな色 / Red and Blue and more various colors (Hard)
ユーザー Kiri8128Kiri8128
提出日時 2020-05-30 03:13:15
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 917 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 80,412 KB
最終ジャッジ日時 2024-04-24 10:52:34
合計ジャッジ時間 6,774 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
11,008 KB
testcase_01 AC 26 ms
10,880 KB
testcase_02 AC 31 ms
10,880 KB
testcase_03 AC 103 ms
15,460 KB
testcase_04 AC 74 ms
13,264 KB
testcase_05 AC 80 ms
13,884 KB
testcase_06 AC 66 ms
13,312 KB
testcase_07 AC 64 ms
13,140 KB
testcase_08 AC 75 ms
13,632 KB
testcase_09 AC 82 ms
13,760 KB
testcase_10 AC 50 ms
12,248 KB
testcase_11 AC 63 ms
13,116 KB
testcase_12 AC 44 ms
12,040 KB
testcase_13 TLE -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

P = 998244353
k = 4
K = k * 27
KK = 1 << K
N, Q = map(int, input().split())
A = [1] * N + [KK + (int(a) - 1) % P for a in input().split()]
pa1 = (1 << k * 18) - ((1 << k * 18) % P)
pa2 = (1 << k * 12) - ((1 << k * 12) % P)
pa3 = (1 << k * 8) - ((1 << k * 8) % P)
def modP(x):
    x -= ((x & m1) >> k * 18) * pa1
    x -= ((x & m2) >> k * 12) * pa2
    x -= ((x & m3) >> k * 8) * pa3
    return x

for i in range(N)[::-1]:
    if i == N - 1 or i and 1 << i.bit_length() - 1 == i:
        if i == N - 1:
            c = 2
        else:
            c *= 2
        m1 = int(("1" * k * 9 + "0" * k * 18) * c, 2)
        m2 = int(("1" * k * 15 + "0" * k * 12) * c, 2)
        m3 = int(("1" * k * 19 + "0" * k * 8) * c, 2)
    A[i] = modP(A[2*i] * A[2*i+1])

t = bin(A[1])[2:] + "_"
X = [int(t[-(i+1) * K - 1:-i * K - 1], 2) % P for i in range((len(t)+K-2) // K)]
for a in [int(a) for a in input().split()]:
    print(X[a])
0