結果

問題 No.142 単なる配列の操作に関する実装問題
ユーザー lam6er
提出日時 2025-04-09 21:01:17
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,200 bytes
コンパイル時間 192 ms
コンパイル使用メモリ 82,836 KB
実行使用メモリ 184,752 KB
最終ジャッジ日時 2025-04-09 21:02:42
合計ジャッジ時間 13,012 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other TLE * 1 -- * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def main():
    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

    # Initialize parity array
    parity = [0] * N
    current = S
    parity[0] = current % 2
    for i in range(1, N):
        current = (X * current + Y) % Z
        parity[i] = current % 2

    Q = int(input[ptr]); ptr += 1
    for _ in range(Q):
        S_k = int(input[ptr]) - 1; ptr += 1  # Convert to 0-based
        T_k = int(input[ptr]) - 1; ptr += 1
        U_k = int(input[ptr]) - 1; ptr += 1
        V_k = int(input[ptr]) - 1; ptr += 1
        
        # Calculate length of the segment
        L = T_k - S_k
        copy_len = L + 1
        copy = parity[S_k : S_k + copy_len]
        # Apply to destination
        dest_start = U_k
        for i in range(copy_len):
            pos = dest_start + i
            if pos >= N:
                break
            parity[pos] ^= copy[i]
    
    # Convert parity to 'E' and 'O'
    result = ['E' if p == 0 else 'O' for p in parity]
    print(''.join(result))

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