結果

問題 No.142 単なる配列の操作に関する実装問題
ユーザー convexineqconvexineq
提出日時 2020-12-19 14:35:27
言語 PyPy3
(7.3.13)
結果
TLE  
実行時間 -
コード長 901 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 81,800 KB
実行使用メモリ 86,320 KB
最終ジャッジ日時 2023-10-21 09:12:55
合計ジャッジ時間 13,766 ms
ジャッジサーバーID
(参考情報)
judge10 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n,s,x,y,z = map(int,input().split())
M = 10**5
dp = [0]*21
a = s
idx = cnt = 0
for i in range(n):
    dp[idx] |= (a%2)<<cnt
    a = (a*x+y)%z
    cnt += 1
    if cnt == M:
        idx += 1
        cnt = 0

def show(dp):
    s = ""
    for i in range(n):
        t = bin(dp[i])[2:][::-1]
        s += t + "0"*(M-len(t))
    return s[:n]

q = int(input())
for _ in range(q):
    s,t,u,v = map(int,input().split())
    s -= 1; t -= 1; u -= 1; v -= 1
    si,sj = s//M, s%M
    ti,tj = t//M, t%M
    if si==ti:
        x = (dp[si]>>sj)&((1<<(tj-sj+1))-1)
    else:
        x = (dp[si]>>sj) | ((dp[ti]&((1<<(tj+1))-1))<<(M-sj))
    #show(dp)
    #print(s,t,bin(x)[2:][::-1],u,v)
    ui,uj = u//M, u%M
    vi,vj = v//M, v%M
    if ui == vi:
        dp[ui] ^= x << uj
    else:
        dp[ui] ^= (x&((1<<(M-uj))-1)) << uj
        dp[vi] ^= x >> (M-uj)

print("".join("O" if i=="1" else "E" for i in show(dp)))
0