結果

問題 No.1675 Strange Minimum Query
ユーザー tcltktcltk
提出日時 2021-10-16 17:50:06
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 1,879 bytes
コンパイル時間 726 ms
コンパイル使用メモリ 80,160 KB
実行使用メモリ 134,464 KB
最終ジャッジ日時 2023-10-17 22:14:15
合計ジャッジ時間 21,385 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 144 ms
85,784 KB
testcase_01 AC 142 ms
85,780 KB
testcase_02 AC 139 ms
85,784 KB
testcase_03 AC 761 ms
109,560 KB
testcase_04 AC 632 ms
106,444 KB
testcase_05 AC 186 ms
97,660 KB
testcase_06 AC 891 ms
118,968 KB
testcase_07 AC 881 ms
116,740 KB
testcase_08 AC 135 ms
85,788 KB
testcase_09 AC 162 ms
88,572 KB
testcase_10 AC 467 ms
113,916 KB
testcase_11 AC 237 ms
105,888 KB
testcase_12 AC 502 ms
115,432 KB
testcase_13 AC 391 ms
133,504 KB
testcase_14 AC 418 ms
132,908 KB
testcase_15 AC 412 ms
134,464 KB
testcase_16 AC 132 ms
85,784 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(key=lambda x: (x[1], x[0], x[2]))
    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