結果
| 問題 | No.142 単なる配列の操作に関する実装問題 |
| コンテスト | |
| ユーザー |
qwewe
|
| 提出日時 | 2025-04-24 12:27:06 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,375 bytes |
| コンパイル時間 | 147 ms |
| コンパイル使用メモリ | 82,124 KB |
| 実行使用メモリ | 291,548 KB |
| 最終ジャッジ日時 | 2025-04-24 12:28:07 |
| 合計ジャッジ時間 | 12,912 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | TLE * 1 -- * 4 |
ソースコード
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 A_bit (1-based)
A = [0] * (N + 1)
A[1] = S % Z
for i in range(2, N + 1):
A[i] = (X * A[i-1] + Y) % Z
A_bit = [a % 2 for a in A]
C = [0] * (N + 1) # 1-based
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 = int(input[ptr]); ptr += 1
V = int(input[ptr]); ptr += 1
L = T_op - S_op + 1
# Check if the source and destination ranges overlap
overlap = not (T_op < U or S_op > V)
# Compute B_temp
if overlap:
B_temp = []
for i in range(S_op, T_op + 1):
B_temp.append(A_bit[i] ^ C[i])
else:
B_temp = [A_bit[i] ^ C[i] for i in range(S_op, T_op + 1)]
# Apply B_temp to destination range U..V
for j in range(U, V + 1):
idx = j - U
C[j] ^= B_temp[idx]
# Generate the result
res = []
for i in range(1, N + 1):
res.append('E' if (A_bit[i] ^ C[i]) == 0 else 'O')
print(''.join(res))
if __name__ == '__main__':
main()
qwewe