結果

問題 No.1625 三角形の質問
ユーザー mkawa2mkawa2
提出日時 2021-07-25 13:50:27
言語 PyPy3
(7.3.15)
結果
MLE  
(最新)
AC  
(最初)
実行時間 -
コード長 3,407 bytes
コンパイル時間 650 ms
コンパイル使用メモリ 87,160 KB
実行使用メモリ 535,808 KB
最終ジャッジ日時 2023-09-28 03:15:21
合計ジャッジ時間 25,797 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 AC 629 ms
115,876 KB
testcase_02 AC 2,607 ms
271,240 KB
testcase_03 AC 2,709 ms
290,164 KB
testcase_04 AC 2,127 ms
252,088 KB
testcase_05 AC 3,822 ms
318,716 KB
testcase_06 TLE -
testcase_07 TLE -
testcase_08 TLE -
testcase_09 TLE -
testcase_10 TLE -
testcase_11 TLE -
testcase_12 TLE -
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 AC 1,696 ms
409,148 KB
testcase_17 AC 1,707 ms
411,404 KB
testcase_18 AC 2,781 ms
330,964 KB
testcase_19 AC 2,212 ms
466,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 10**16
md = 998244353
# md = 10**9+7

# 内部で1-indexedに変えるので入力は0-indexedでよい
# jは内部で座圧する
# nはiの最大値+1(リストの長さ)
class BitMax2D:
    class Node:
        def __init__(self):
            self.st = set()

        def comp(self):
            self.enc = {a: i for i, a in enumerate(sorted(self.st))}
            self.bit = BitMax(len(self.enc))

        def update(self, j, val):
            j = self.enc[j]
            self.bit.update(j, val)

        def max(self, j):
            j = self.enc[j]
            return self.bit.max(j)

    def __init__(self, n):
        self.inf = 10**16
        self.n = n
        self.table = [self.Node() for _ in range(n+1)]

    # インデックスの先読み
    def pre_read(self, i, j):
        i = k = i+1
        while i <= self.n:
            self.table[i].st.add(j)
            i += i & -i
        while k > 0:
            self.table[k].st.add(j)
            k -= k & -k

    # 先読み終了後に準備
    def prep(self):
        for i in range(self.n):
            self.table[i+1].comp()

    def update(self, i, j, val):
        i += 1
        while i <= self.n:
            self.table[i].update(j, val)
            i += i & -i

    def max(self, i, j):
        i += 1
        res = -self.inf
        while i > 0:
            cur = self.table[i].max(j)
            if cur > res: res = cur
            i -= i & -i
        return res

class BitMax:
    def __init__(self, n):
        self.inf = 10**16
        self.n = n
        self.table = [-self.inf]*(self.n+1)

    def update(self, i, x):
        i += 1
        while i <= self.n:
            if x > self.table[i]: self.table[i] = x
            i += i & -i

    def max(self, i):
        i += 1
        res = -self.inf
        while i > 0:
            if self.table[i] > res: res = self.table[i]
            i -= i & -i
        return res

def space(a, b, c, d, e, f):
    a, b, c, d = a-e, b-f, c-e, d-f
    return abs(a*d-b*c)

n, q = LI()
bit = BitMax2D(n+q)

task = []
for _ in range(n):
    a, b, c, d, e, f = LI()
    l = min(a, c, e)
    r = max(a, c, e)
    s = space(a, b, c, d, e, f)
    task.append((l, 0, r, s, 0))
    bit.pre_read(0, r)

ans = []
for i in range(q):
    tx = LI()
    if tx[0] == 1:
        _, a, b, c, d, e, f = tx
        l = min(a, c, e)
        r = max(a, c, e)
        s = space(a, b, c, d, e, f)
        task.append((l, 0, r, s, i+1))
    else:
        _, l, r = tx
        task.append((l, 1, r, i+1))
    bit.pre_read(i+1, r)

bit.prep()
task.sort(key=lambda x: (-x[0], x[1]))
for tt in task:
    if len(tt) == 5:
        l, _, r, s, i = tt
        bit.update(i, r, s)
    else:
        l, _, r, i = tt
        mx = bit.max(i, r)
        if mx == -inf: mx = -1
        ans.append((i, mx))

ans.sort()
for i, s in ans: print(s)
0