結果

問題 No.1675 Strange Minimum Query
ユーザー 👑 timitimi
提出日時 2021-09-13 11:49:18
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,712 bytes
コンパイル時間 594 ms
コンパイル使用メモリ 87,168 KB
実行使用メモリ 136,864 KB
最終ジャッジ日時 2023-09-07 17:18:28
合計ジャッジ時間 42,814 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,524 KB
testcase_01 AC 74 ms
71,372 KB
testcase_02 AC 76 ms
71,388 KB
testcase_03 AC 1,022 ms
100,560 KB
testcase_04 AC 961 ms
99,988 KB
testcase_05 AC 207 ms
83,844 KB
testcase_06 AC 1,225 ms
112,744 KB
testcase_07 AC 1,332 ms
108,512 KB
testcase_08 AC 89 ms
76,884 KB
testcase_09 AC 149 ms
78,772 KB
testcase_10 AC 822 ms
113,368 KB
testcase_11 AC 417 ms
100,296 KB
testcase_12 AC 877 ms
113,736 KB
testcase_13 AC 940 ms
128,628 KB
testcase_14 AC 1,290 ms
133,160 KB
testcase_15 AC 1,153 ms
134,160 KB
testcase_16 AC 75 ms
71,312 KB
testcase_17 AC 540 ms
89,356 KB
testcase_18 AC 641 ms
91,608 KB
testcase_19 AC 836 ms
109,056 KB
testcase_20 AC 1,454 ms
116,412 KB
testcase_21 AC 1,380 ms
118,416 KB
testcase_22 AC 1,748 ms
124,340 KB
testcase_23 AC 1,333 ms
106,940 KB
testcase_24 AC 1,272 ms
109,240 KB
testcase_25 AC 963 ms
97,800 KB
testcase_26 AC 631 ms
95,608 KB
testcase_27 AC 1,271 ms
117,496 KB
testcase_28 AC 798 ms
106,224 KB
testcase_29 AC 654 ms
106,156 KB
testcase_30 AC 638 ms
96,756 KB
testcase_31 AC 1,667 ms
116,200 KB
testcase_32 TLE -
testcase_33 TLE -
testcase_34 TLE -
testcase_35 AC 1,901 ms
136,592 KB
testcase_36 AC 1,910 ms
136,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.readline
N,Q=map(int, input().split())
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)内の最小値を求める(最大値の時はminをmaxに変えよう)
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

B=[list(map(int, input().split())) for i in range(Q)]
B=sorted(B,key=lambda x:x[2])

for l,r,b in B:
  update(l-1,r,b)
  
for l,r,b in B:
  if b!=query(l-1,r):
    print(-1)
    exit()
    
A=[]
for i in range(N):
  A.append(query(i,i+1))
print(*A)
0