結果

問題 No.142 単なる配列の操作に関する実装問題
ユーザー gew1fw
提出日時 2025-06-12 19:59:27
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,199 bytes
コンパイル時間 140 ms
コンパイル使用メモリ 82,540 KB
実行使用メモリ 192,224 KB
最終ジャッジ日時 2025-06-12 20:02:42
合計ジャッジ時間 12,904 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other TLE * 1 -- * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    import sys
    input = sys.stdin.read
    data = input().split()
    
    idx = 0
    N = int(data[idx])
    idx += 1
    S = int(data[idx])
    idx += 1
    X = int(data[idx])
    idx += 1
    Y = int(data[idx])
    idx += 1
    Z = int(data[idx])
    idx += 1

    # Compute initial A mod Z
    a = [0] * N
    a[0] = S % Z
    for i in range(1, N):
        a[i] = (X * a[i-1] + Y) % Z

    # Compute parities
    par = [x % 2 for x in a]

    Q = int(data[idx])
    idx += 1

    for _ in range(Q):
        S_op = int(data[idx])
        idx += 1
        T_op = int(data[idx])
        idx += 1
        U_op = int(data[idx])
        idx += 1
        V_op = int(data[idx])
        idx += 1

        s = S_op - 1
        t = T_op - 1
        u = U_op - 1
        v = V_op - 1

        len_b = t - s + 1
        b = par[s:s + len_b]

        for i in range(len_b):
            pos = u + i
            if pos >= N:
                break
            par[pos] ^= b[i]

    # Prepare the output
    output = []
    for p in par:
        if p == 0:
            output.append('E')
        else:
            output.append('O')
    print(''.join(output))

if __name__ == "__main__":
    main()
0