結果
| 問題 |
No.142 単なる配列の操作に関する実装問題
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 20:01:42 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,386 bytes |
| コンパイル時間 | 157 ms |
| コンパイル使用メモリ | 82,196 KB |
| 実行使用メモリ | 201,872 KB |
| 最終ジャッジ日時 | 2025-06-12 20:05:28 |
| 合計ジャッジ時間 | 13,011 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | TLE * 1 -- * 4 |
ソースコード
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
Q = int(input[ptr]); ptr +=1
# Generate initial array mod Z
A = [0]*(N+1) # 1-based indexing
A[1] = S % Z
for i in range(2, N+1):
A[i] = (X * A[i-1] + Y) % Z
# Convert to binary (parity)
binary = [0]*(N+1)
for i in range(1, N+1):
binary[i] = A[i] % 2
for _ in range(Q):
if ptr >= len(input):
S_op = 0
else:
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
L = T_op - S_op + 1
# Make a copy of B
B = [binary[i] for i in range(S_op, T_op+1)]
# Apply to [U, V]
for k in range(U_op, V_op+1):
offset = k - U_op
s_pos = S_op + offset
if s_pos < S_op or s_pos > T_op:
continue # shouldn't happen
binary[k] ^= B[offset]
# Build the result string
res = []
for i in range(1, N+1):
if binary[i] == 0:
res.append('E')
else:
res.append('O')
print(''.join(res))
if __name__ == '__main__':
main()
gew1fw