結果

問題 No.2901 Logical Sum of Substring
ユーザー 高岡コウダイ
提出日時 2024-09-25 19:45:26
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 688 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 40,368 KB
最終ジャッジ日時 2024-09-25 19:45:32
合計ジャッジ時間 5,209 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 2
other WA * 6 TLE * 1 -- * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K = map(int, input().split())
datas = list(map(int, input().split()))

def process_data(datas, key, N):
    S = [0] * (N+1)
    current = 0
    for i in range(N):
        current |= datas[i]
        if current == key:
            S[i+1] = S[i] + 1
        else:
            S[i+1] = S[i]
    return S

key = (1 << K) - 1
Q = int(input())
S = process_data(datas, key, N)

for _ in range(Q):
    query = list(map(int, input().split()))
    if query[0] == 1:
        _, i, v = query
        datas[i-1] = v
        S = process_data(datas, key, N)
    elif query[0] == 2:
        _, l, r = query
        if S[r] - S[l-1] > 0:
            print(r - l + 1)
        else:
            print(-1)
0