結果

問題 No.814 ジジ抜き
ユーザー lam6er
提出日時 2025-03-26 15:46:21
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 624 bytes
コンパイル時間 445 ms
コンパイル使用メモリ 82,752 KB
実行使用メモリ 77,400 KB
最終ジャッジ日時 2025-03-26 15:46:42
合計ジャッジ時間 8,907 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other MLE * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

def xor_upto(n):
    mod = n % 4
    if mod == 0:
        return n
    elif mod == 1:
        return 1
    elif mod == 2:
        return n + 1
    else:  # mod == 3
        return 0

def xor_from_a_to_b(a, b):
    if a > b:
        return 0
    return xor_upto(b) ^ xor_upto(a - 1)

n = int(input())
x = 0
for _ in range(n):
    k, l, d = map(int, input().split())
    step = 1 << d
    mask = l % step
    a = l // step
    start = a
    end = a + k - 1
    upper_xor = xor_from_a_to_b(start, end)
    if k % 2 == 1:
        xor_i = (upper_xor << d) | mask
    else:
        xor_i = (upper_xor << d)
    x ^= xor_i
print(x)
0