結果

問題 No.1675 Strange Minimum Query
ユーザー puznekopuzneko
提出日時 2021-11-07 00:31:05
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,924 bytes
コンパイル時間 196 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 175,312 KB
最終ジャッジ日時 2024-04-25 12:41:35
合計ジャッジ時間 24,054 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,608 KB
testcase_01 AC 37 ms
52,480 KB
testcase_02 AC 36 ms
52,480 KB
testcase_03 AC 749 ms
165,476 KB
testcase_04 AC 765 ms
162,500 KB
testcase_05 AC 156 ms
85,376 KB
testcase_06 AC 813 ms
172,892 KB
testcase_07 AC 933 ms
172,272 KB
testcase_08 AC 52 ms
60,672 KB
testcase_09 AC 130 ms
77,824 KB
testcase_10 AC 632 ms
119,296 KB
testcase_11 AC 423 ms
104,392 KB
testcase_12 AC 718 ms
119,552 KB
testcase_13 AC 1,155 ms
175,312 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 39 ms
52,608 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin
n, q, *indata = map(int, stdin.read().split())
offset = 0
querytable = []
for i in range(q):
    s, t, b  = indata[offset + 3*i],indata[offset + 3*i+1],indata[offset + 3*i+2]
    querytable.append((b,s,t))

# N: 処理する区間の長さ

INF = 10**9

LV = (n+1).bit_length()
N0 = 2**LV
data = [INF]*(2*N0)
lazy = [None]*(2*N0)

# 伝搬対象の区間を求める
def gindex(l, r):
    L = (l + N0) >> 1; R = (r + N0) >> 1
    lc = 0 if l & 1 else (L & -L).bit_length()
    rc = 0 if r & 1 else (R & -R).bit_length()
    for i in range(LV):
        if rc <= i:
            yield R
        if L < R and lc <= i:
            yield L
        L >>= 1; R >>= 1

# 遅延伝搬処理
def propagates(*ids):
    for i in reversed(ids):
        v = lazy[i-1]
        if v is None:
            continue
        lazy[2*i-1] = data[2*i-1] = lazy[2*i] = data[2*i] = v
        lazy[i-1] = None

# 区間[l, r)をxで更新
def update(l, r, x):
    *ids, = gindex(l, r)
    propagates(*ids)

    L = N0 + l; R = N0 + r
    while L < R:
        if R & 1:
            R -= 1
            lazy[R-1] = data[R-1] = x
        if L & 1:
            lazy[L-1] = data[L-1] = x
            L += 1
        L >>= 1; R >>= 1
    for i in ids:
        data[i-1] = min(data[2*i-1], data[2*i])

# 区間[l, r)内の最小値を求める
def query(l, r):
    propagates(*gindex(l, r))
    L = N0 + l; R = N0 + r

    s = INF
    while L < R:
        if R & 1:
            R -= 1
            s = min(s, data[R-1])
        if L & 1:
            s = min(s, data[L-1])
            L += 1
        L >>= 1; R >>= 1
    return s

for i in range(q):
    b, s, t = querytable[i]
    update(s,t+1,b)

for i in range(q):
    b, s, t = querytable[i]
    val = query(s,t+1)
    if val != b:
        print(-1)
        exit()

ans = [0 for i in range(n)]
for i in range(n):
    val = query(i+1,i+2)
    ans[i] = str(val)

L=' '.join(ans)
print(L)
0