結果

問題 No.1074 増殖
ユーザー Kiri8128Kiri8128
提出日時 2020-05-17 16:15:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 742 ms / 2,000 ms
コード長 1,409 bytes
コンパイル時間 579 ms
コンパイル使用メモリ 81,856 KB
実行使用メモリ 92,728 KB
最終ジャッジ日時 2023-10-26 00:39:37
合計ジャッジ時間 7,188 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
59,904 KB
testcase_01 AC 43 ms
59,908 KB
testcase_02 AC 43 ms
59,904 KB
testcase_03 AC 43 ms
59,904 KB
testcase_04 AC 45 ms
59,908 KB
testcase_05 AC 53 ms
64,688 KB
testcase_06 AC 742 ms
92,728 KB
testcase_07 AC 331 ms
87,780 KB
testcase_08 AC 402 ms
89,692 KB
testcase_09 AC 630 ms
91,556 KB
testcase_10 AC 437 ms
87,884 KB
testcase_11 AC 427 ms
87,928 KB
testcase_12 AC 418 ms
88,000 KB
testcase_13 AC 557 ms
88,868 KB
testcase_14 AC 565 ms
88,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda: sys.stdin.readline().rstrip()
N = int(input())
X = [[] for _ in range(4)]
for _ in range(N):
    xa, ya, xb, yb = map(int, input().split())
    X[0].append((xb, yb))
    X[1].append((xb, -ya))
    X[2].append((-xa, -ya))
    X[3].append((-xa, yb))

def calc(L):
    K = 144
    A = [(0, 0, 0, -1) for _ in range(K * K)] # max, min, sum, lazy
    B = [[0] * K for _ in range(K)]
    RE = []
    for x, y in L:
        xx = x // K
        yy = x % K
        re = 0
        for i in range(xx):
            ma, mi, su, la = A[i]
            if y <= mi: continue
            re -= su
            if ma <= y:
                A[i] = (y, y, y * K, y)
            else:
                if la >= 0:
                    for j in range(K):
                        B[i][j] = la
                for j in range(K):
                    B[i][j] = max(B[i][j], y)
                A[i] = (max(B[i]), min(B[i]), sum(B[i]), -1)
            re += A[i][2]
            
        ma, mi, su, la = A[xx]
        re -= su
        if la >= 0:
            for j in range(K):
                B[xx][j] = la
        
        for j in range(yy):
            B[xx][j] = max(B[xx][j], y)
        A[xx] = (max(B[xx]), min(B[xx]), sum(B[xx]), -1)
        re += A[xx][2]
        RE.append(re)
    return RE

ANS = [0] * N
for x in X:
    for i, a in enumerate(calc(x)):
        ANS[i] += a
print("\n".join(map(str, ANS)))
0