結果
| 問題 | No.961 Vibrant Fillumination | 
| コンテスト | |
| ユーザー |  gew1fw | 
| 提出日時 | 2025-06-12 21:19:14 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,686 bytes | 
| コンパイル時間 | 309 ms | 
| コンパイル使用メモリ | 82,344 KB | 
| 実行使用メモリ | 848,268 KB | 
| 最終ジャッジ日時 | 2025-06-12 21:19:23 | 
| 合計ジャッジ時間 | 4,035 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 WA * 1 | 
| other | MLE * 1 -- * 47 | 
ソースコード
import sys
def main():
    sys.setrecursionlimit(1 << 25)
    input = sys.stdin.read().split()
    ptr = 0
    N = int(input[ptr])
    ptr += 1
    h_list = list(map(int, input[ptr:ptr+N]))
    ptr += N
    max_coord = 2 * N + 2
    bit = BIT2D(max_coord, max_coord)
    for _ in range(N):
        a = int(input[ptr])
        b = int(input[ptr+1])
        c = int(input[ptr+2])
        d = int(input[ptr+3])
        e = int(input[ptr+4]) - 1  # converting to 0-based
        ptr += 5
        x1 = a + 1
        y1 = b + 1
        x2 = c
        y2 = d
        v = h_list[e]
        # Update four corners
        bit.update(x1, y1, v)
        bit.update(x1, y2 + 1, v)
        bit.update(x2 + 1, y1, v)
        bit.update(x2 + 1, y2 + 1, v)
    Q = int(input[ptr])
    ptr += 1
    output = []
    for _ in range(Q):
        p = int(input[ptr])
        q = int(input[ptr+1])
        ptr += 2
        x = p + 1
        y = q + 1
        res = bit.query(x, y)
        output.append(str(res))
    print('\n'.join(output))
class BIT2D:
    def __init__(self, max_x, max_y):
        self.max_x = max_x
        self.max_y = max_y
        self.tree = [[0]*(max_y + 2) for _ in range(max_x + 2)]
    
    def update(self, x, y, val):
        while x <= self.max_x:
            y0 = y
            while y0 <= self.max_y:
                self.tree[x][y0] ^= val
                y0 += y0 & -y0
            x += x & -x
    
    def query(self, x, y):
        res = 0
        while x > 0:
            y0 = y
            while y0 > 0:
                res ^= self.tree[x][y0]
                y0 -= y0 & -y0
            x -= x & -x
        return res
if __name__ == '__main__':
    main()
            
            
            
        