結果

問題 No.1675 Strange Minimum Query
ユーザー tcltktcltk
提出日時 2021-10-16 14:24:35
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,847 bytes
コンパイル時間 528 ms
コンパイル使用メモリ 81,724 KB
実行使用メモリ 132,256 KB
最終ジャッジ日時 2023-10-17 22:10:44
合計ジャッジ時間 23,195 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
85,952 KB
testcase_01 AC 126 ms
85,948 KB
testcase_02 AC 126 ms
85,948 KB
testcase_03 AC 712 ms
110,832 KB
testcase_04 AC 582 ms
106,672 KB
testcase_05 AC 174 ms
97,796 KB
testcase_06 AC 799 ms
112,888 KB
testcase_07 AC 805 ms
113,196 KB
testcase_08 AC 126 ms
85,952 KB
testcase_09 AC 151 ms
88,816 KB
testcase_10 AC 441 ms
114,056 KB
testcase_11 AC 223 ms
106,044 KB
testcase_12 AC 479 ms
115,828 KB
testcase_13 AC 361 ms
129,528 KB
testcase_14 AC 396 ms
132,256 KB
testcase_15 AC 395 ms
132,228 KB
testcase_16 AC 127 ms
85,952 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 #

#!/usr/bin/env python3
# from typing import *

import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq


def input():
    return sys.stdin.readline()[:-1]


# sys.setrecursionlimit(1000000)

# _INPUT = """5 3
# 1 3 1
# 3 5 3
# 4 5 4

# """
# sys.stdin = io.StringIO(_INPUT)

INF = 10**10

class SegTree_Update_QRMin:
    def __init__(self, a) -> None:
        n = len(a)
        self.n0 = 1 << (n-1).bit_length()
        self.data = ([INF] * self.n0) + a + ([INF] * (self.n0-n))
        for i in reversed(range(1, self.n0)):
            self.data[i] = min(self.data[i*2], self.data[i*2+1])
    def query_rmin(self, l, r):
        l += self.n0
        r += self.n0
        s = INF
        while l < r:
            if l & 1:
                s = min(s, self.data[l])
                l += 1
            if r & 1:
                s = min(s, self.data[r-1])
                r -= 1
            l >>= 1
            r >>= 1
        return s
    def update(self, i, x):
        i += self.n0
        self.data[i] = x
        while i > 0:
            i >>= 1
            self.data[i] = min(self.data[i*2], self.data[i*2+1])
    def get_value(self, i) -> int:
        return self.data[i+self.n0]

def solve(N, Q, Query):
    Query.sort()
    result = [10**9] * N
    k = 0
    for i in range(N):
        if k < Q:
            l, r, b = Query[k]
            if l <= i <= r:
                result[i] = b
                k += 1
            elif r < i:
                return [-1]
    
    seg_tree = SegTree_Update_QRMin(result)
    for l, r, b in Query:
        if seg_tree.query_rmin(l, r+1) != b:
            return [-1]
    return result


N, Q = map(int, input().split())
Query = []
for _ in range(Q):
    l, r, b = map(int, input().split())
    Query.append((l-1, r-1, b))

print(*solve(N, Q, Query))
0