結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 46 ms
55,424 KB
testcase_02 AC 47 ms
55,168 KB
testcase_03 AC 1,516 ms
104,704 KB
testcase_04 AC 1,429 ms
102,016 KB
testcase_05 AC 215 ms
83,456 KB
testcase_06 AC 1,793 ms
109,364 KB
testcase_07 AC 1,979 ms
111,360 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 1,860 ms
117,232 KB
testcase_14 TLE -
testcase_15 TLE -
testcase_16 AC 48 ms
54,912 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 TLE -
testcase_21 WA -
testcase_22 TLE -
testcase_23 AC 1,907 ms
102,708 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 658 ms
87,936 KB
testcase_27 AC 1,514 ms
104,220 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