結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
70,888 KB
testcase_01 AC 73 ms
71,052 KB
testcase_02 AC 88 ms
70,980 KB
testcase_03 AC 773 ms
115,868 KB
testcase_04 AC 786 ms
120,820 KB
testcase_05 AC 295 ms
93,644 KB
testcase_06 AC 861 ms
120,860 KB
testcase_07 AC 992 ms
128,836 KB
testcase_08 WA -
testcase_09 AC 143 ms
78,476 KB
testcase_10 AC 520 ms
122,508 KB
testcase_11 WA -
testcase_12 AC 571 ms
125,600 KB
testcase_13 AC 515 ms
140,128 KB
testcase_14 AC 575 ms
153,204 KB
testcase_15 AC 634 ms
153,128 KB
testcase_16 AC 70 ms
70,916 KB
testcase_17 AC 393 ms
93,996 KB
testcase_18 AC 498 ms
98,872 KB
testcase_19 WA -
testcase_20 AC 806 ms
128,880 KB
testcase_21 AC 751 ms
129,312 KB
testcase_22 AC 890 ms
141,500 KB
testcase_23 AC 740 ms
117,940 KB
testcase_24 AC 723 ms
119,264 KB
testcase_25 AC 554 ms
106,560 KB
testcase_26 WA -
testcase_27 AC 710 ms
128,004 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 872 ms
126,228 KB
testcase_32 AC 1,146 ms
153,856 KB
testcase_33 AC 1,098 ms
151,700 KB
testcase_34 AC 1,108 ms
151,372 KB
testcase_35 AC 1,054 ms
154,012 KB
testcase_36 AC 1,106 ms
153,896 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 = [1] * 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 = [1] * 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