結果

問題 No.1675 Strange Minimum Query
ユーザー SidewaysOwlSidewaysOwl
提出日時 2021-09-11 00:13:11
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,991 bytes
コンパイル時間 638 ms
コンパイル使用メモリ 87,124 KB
実行使用メモリ 154,212 KB
最終ジャッジ日時 2023-09-03 13:04:10
合計ジャッジ時間 29,592 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,152 KB
testcase_01 AC 74 ms
71,400 KB
testcase_02 AC 75 ms
71,660 KB
testcase_03 AC 809 ms
116,000 KB
testcase_04 AC 857 ms
121,304 KB
testcase_05 AC 302 ms
93,580 KB
testcase_06 AC 916 ms
121,216 KB
testcase_07 AC 1,026 ms
129,084 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 545 ms
140,628 KB
testcase_14 AC 605 ms
153,492 KB
testcase_15 AC 673 ms
153,716 KB
testcase_16 AC 76 ms
71,624 KB
testcase_17 AC 422 ms
94,384 KB
testcase_18 AC 502 ms
99,324 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 989 ms
141,668 KB
testcase_23 AC 827 ms
118,640 KB
testcase_24 AC 760 ms
120,356 KB
testcase_25 AC 596 ms
106,820 KB
testcase_26 WA -
testcase_27 AC 783 ms
128,224 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 957 ms
126,828 KB
testcase_32 AC 1,240 ms
153,088 KB
testcase_33 AC 1,194 ms
152,536 KB
testcase_34 AC 1,208 ms
151,808 KB
testcase_35 AC 1,115 ms
154,212 KB
testcase_36 AC 1,158 ms
153,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class SegmrntTree:
    
    def __init__(self,arr,func,i_ele):
        self.i_ele = i_ele
        self.func = func
        arr_len = len(arr)
        self.tree_len = 2 ** (arr_len-1).bit_length()  * 2
        self.tree = [i_ele] * self.tree_len
        for i in range(arr_len):
            self.tree[i + self.tree_len // 2] = arr[i]
        for i in range(self.tree_len // 2 -1,0,-1):
            self.tree[i] = func(self.tree[i * 2],self.tree[i * 2 + 1])
    
    def query_range(self,l,r):
        res = self.i_ele
        l += self.tree_len // 2 - 1
        r += self.tree_len // 2 
        while l < r:
            if l & 1:
                res = self.func(res,self.tree[l])
                l += 1
            if r & 1:
                res = self.func(res,self.tree[r-1])
                r -= 1
            l >>= 1
            r >>= 1
        return res
    
    def query(self,l):
        return self.tree[l + self.tree_len // 2 - 1]
    
    def update(self,l,x):
        l += self.tree_len // 2 - 1
        self.tree[l] = x
        def calc(l):
            if l & 1:
                l -=1
            return l >> 1
        while calc(l):
            if l & 1:
                self.tree[calc(l)] = self.func(self.tree[l],self.tree[l-1])
            else:
                self.tree[calc(l)] = self.func(self.tree[l],self.tree[l+1])
            l = calc(l)
n,q = map(int,input().split())
lis = [list(map(int,input().split())) for _ in range(q)]
tree = [0] * q
st = SegmrntTree(tree,max,0)
ll = [[] for _ in range(n)]
lr = [[] for _ in range(n+1)]
for i in range(q):
    l,r,b = lis[i]
    ll[l-1].append((i+1,b))
    lr[r].append(i+1)
B = [0] * n
for i in range(n):
    for l,b in ll[i]:
        st.update(l,b)
    for r in lr[i]:
        st.update(r,0)
    val = st.query_range(1,q)
    B[i] = val
flg = True
st = SegmrntTree(B,min,10**10)
for i in range(q):
    l,r,b = lis[i]
    val = st.query_range(l,r)
    if val != b:
        flg = False
if flg:
    print(*B)
else:
    print(-1)
0