結果

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

ソースコード

diff #

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

    # Generate initial array A with parity (0 for even, 1 for odd)
    A = [0] * N
    current = S
    A[0] = current % 2
    for i in range(1, N):
        current = (X * current + Y) % Z
        A[i] = current % 2

    Q = int(input[ptr]); ptr += 1
    for _ in range(Q):
        S_op = int(input[ptr]); ptr += 1
        T_op = int(input[ptr]); ptr += 1
        U_op = int(input[ptr]); ptr += 1
        V_op = int(input[ptr]); ptr += 1

        # Adjust for 0-based indices
        S_0 = S_op - 1
        T_0 = T_op - 1
        U_0 = U_op - 1
        V_0 = V_op - 1

        # Extract B as a list of parities
        B = A[S_0 : T_0 + 1]

        # Apply XOR to A[U..V]
        for i in range(U_0, V_0 + 1):
            A[i] ^= B[i - U_0]

    # Convert to the required output string
    output = []
    for num in A:
        if num == 0:
            output.append('E')
        else:
            output.append('O')
    print(''.join(output))

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