結果

問題 No.803 Very Limited Xor Subset
ユーザー titia
提出日時 2025-01-28 06:08:12
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 738 bytes
コンパイル時間 340 ms
コンパイル使用メモリ 12,288 KB
実行使用メモリ 10,496 KB
最終ジャッジ日時 2025-01-28 06:08:16
合計ジャッジ時間 3,884 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

# https://betrue12.hateblo.jp/entry/2019/03/18/005750

import sys
input = sys.stdin.readline

mod=10**9+7

N,M,X=map(int,input().split())
A=list(map(int,input().split()))

c=32
for i in range(M):
    typ,l,r=map(int,input().split())
    l-=1
    r-=1

    if typ==0:
        for i in range(l,r+1):
            A[i]|=(1<<c)
    else:
        for i in range(l,r+1):
            A[i]|=(1<<c)
        X|=(1<<c)

    c+=1

# xorの掃き出し法・基底

BASE=[]

def sweep(x):
    for b in BASE:
        if b^x<x:
            x=b^x
    return x

for x in A:
    k=sweep(x)
    if k!=0: # 掃き出した値が0でないなら基底に入れる。
        BASE.append(k)

if sweep(X)!=0:
    print(0)
else:
    print(pow(2,N-len(BASE),mod))
0