結果

問題 No.1675 Strange Minimum Query
ユーザー terasaterasa
提出日時 2022-06-17 01:22:31
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 3,157 bytes
コンパイル時間 182 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 124,648 KB
最終ジャッジ日時 2024-04-16 15:17:18
合計ジャッジ時間 46,409 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 45 ms
55,040 KB
testcase_02 AC 45 ms
54,784 KB
testcase_03 AC 1,560 ms
105,088 KB
testcase_04 AC 1,511 ms
101,888 KB
testcase_05 AC 215 ms
83,456 KB
testcase_06 AC 1,863 ms
109,732 KB
testcase_07 TLE -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 1,909 ms
117,364 KB
testcase_14 TLE -
testcase_15 TLE -
testcase_16 AC 47 ms
55,296 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 TLE -
testcase_21 WA -
testcase_22 TLE -
testcase_23 TLE -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 678 ms
88,192 KB
testcase_27 AC 1,600 ms
104,212 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import pypyjit
import itertools
import heapq
import math
from collections import deque, defaultdict
import bisect

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
pypyjit.set_param('max_unroll_recursion=-1')


def index_lt(a, x):
    'return largest index s.t. A[i] < x or -1 if it does not exist'
    return bisect.bisect_left(a, x) - 1


def index_le(a, x):
    'return largest index s.t. A[i] <= x or -1 if it does not exist'
    return bisect.bisect_right(a, x) - 1


def index_gt(a, x):
    'return smallest index s.t. A[i] > x or len(a) if it does not exist'
    return bisect.bisect_right(a, x)


def index_ge(a, x):
    'return smallest index s.t. A[i] >= x or len(a) if it does not exist'
    return bisect.bisect_left(a, x)


class LazySegTree_RUQ:
    def __init__(self, N, func, e):
        self.N = N
        self.func = func
        self.X = [e] * (N << 1)
        self.lazy = [None] * (N << 1)
        self.e = e

    def build(self, seq):
        for i in range(self.N):
            self.X[self.N + i] = seq[i]
        for i in range(self.N)[::-1]:
            self.X[i] = self.func(self.X[i << 1], self.X[i << 1 | 1])

    def gindex(self, l, r):
        l += self.N
        r += self.N
        lm = l >> (l & -l).bit_length()
        rm = r >> (r & -r).bit_length()
        while r > l:
            if l <= lm:
                yield l
            if r <= rm:
                yield r
            r >>= 1
            l >>= 1
        while l:
            yield l
            l >>= 1

    def propagates(self, *ids):
        for i in ids[::-1]:
            v = self.lazy[i]
            if v is None:
                continue
            self.lazy[i << 1] = v
            self.lazy[i << 1 | 1] = v
            self.X[i << 1] = v
            self.X[i << 1 | 1] = v
            self.lazy[i] = None

    def update(self, L, R, x):
        *ids, = self.gindex(L, R)
        self.propagates(*ids)
        L += self.N
        R += self.N
        while L < R:
            if L & 1:
                self.lazy[L] = x
                self.X[L] = x
                L += 1
            if R & 1:
                R -= 1
                self.lazy[R] = x
                self.X[R] = x
            L >>= 1
            R >>= 1
        for i in ids:
            self.X[i] = self.func(self.X[i << 1], self.X[i << 1 | 1])

    def query(self, L, R):
        *ids, = self.gindex(L, R)
        self.propagates(*ids)
        L += self.N
        R += self.N
        vL = self.e
        vR = self.e
        while L < R:
            if L & 1:
                vL = self.func(vL, self.X[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.func(self.X[R], vR)
            L >>= 1
            R >>= 1
        return self.func(vL, vR)


N, Q = map(int, input().split())
query = [tuple(map(int, input().split())) for _ in range(Q)]
query.sort(key=lambda x: x[2])

lst = LazySegTree_RUQ(N, min, 10 ** 9)
lst.build([10 ** 9] * N)

for l, r, B in query:
    l -= 1
    lst.update(l, r, B)

for l, r, B in query:
    l -= 1
    m = lst.query(l, r)
    if m != B:
        print(-1)
        exit()
print(*lst.X[N:])
0