結果

問題 No.142 単なる配列の操作に関する実装問題
ユーザー maspymaspy
提出日時 2020-05-14 18:41:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,170 bytes
コンパイル時間 104 ms
コンパイル使用メモリ 11,028 KB
実行使用メモリ 151,596 KB
最終ジャッジ日時 2023-10-13 17:10:14
合計ジャッジ時間 20,019 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 2,115 ms
151,352 KB
testcase_04 AC 3,442 ms
151,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

B = 10**5 + 10

N, S, X, Y, Z = map(int, readline().split())

def gen_A():
    x = S
    for _ in range(N):
        yield str(x & 1)
        x = (X * x + Y) % Z

A_str = ''.join(gen_A())

nums = []
for i in range((N + B - 1) // B):
    nums.append(int(A_str[B * i:B * i + B][::-1], 2))

def get(L, R):
    i = L // B
    L -= B * i
    R -= B * i
    if B >= R:
        yield (R - L, nums[i] >> L & ((1 << R - L) - 1))
        return
    yield (B - L, nums[i] >> L)
    R -= B
    yield (R, nums[i + 1] & ((1 << R) - 1))

def add(L, n, x):
    i = L // B
    L -= B * i
    if L + n <= B:
        nums[i] ^= x << L
        return
    nums[i] ^= (x & ((1 << B - L) - 1)) << L
    x >>= (B - L)
    nums[i + 1] ^= x

Q = int(readline())
m = map(int, read().split())
for s, t, u, v in zip(m, m, m, m):
    p = u - 1
    for n, x in get(s - 1, t):
        add(p, n, x)
        p += n

for i in range(len(nums)):
    nums[i] = bin(nums[i])[2:][::-1]
    nums[i] += '0' * (B - len(nums[i]))

x = ''.join(nums)[:N]
print(x.replace('0', 'E').replace('1', 'O'))
0