結果
問題 | No.1074 増殖 |
ユーザー | 👑 tamato |
提出日時 | 2020-06-05 23:01:42 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 294 ms / 2,000 ms |
コード長 | 2,376 bytes |
コンパイル時間 | 281 ms |
コンパイル使用メモリ | 87,364 KB |
実行使用メモリ | 88,184 KB |
最終ジャッジ日時 | 2023-08-22 17:05:59 |
合計ジャッジ時間 | 3,652 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 72 ms
73,064 KB |
testcase_01 | AC | 71 ms
72,880 KB |
testcase_02 | AC | 71 ms
72,912 KB |
testcase_03 | AC | 71 ms
72,604 KB |
testcase_04 | AC | 70 ms
72,908 KB |
testcase_05 | AC | 71 ms
72,864 KB |
testcase_06 | AC | 156 ms
86,064 KB |
testcase_07 | AC | 178 ms
86,316 KB |
testcase_08 | AC | 220 ms
86,548 KB |
testcase_09 | AC | 292 ms
87,004 KB |
testcase_10 | AC | 109 ms
84,368 KB |
testcase_11 | AC | 186 ms
86,368 KB |
testcase_12 | AC | 181 ms
86,352 KB |
testcase_13 | AC | 294 ms
88,184 KB |
testcase_14 | AC | 284 ms
87,184 KB |
ソースコード
mod = 1000000007 eps = 10**-9 K = 20000 def main(): import sys input = sys.stdin.buffer.readline class Bit: def __init__(self, n): self.size = n self.tree = [0] * (n + 1) def sum(self, i): s = 0 while i > 0: s += self.tree[i] i -= i & -i return s def add(self, i, x): while i <= self.size: self.tree[i] += x i += i & -i def lower_bound(self, w): if w <= 0: return 0 x = 0 k = 1 << (self.size.bit_length() - 1) while k: if x + k <= self.size and self.tree[x + k] < w: w -= self.tree[x + k] x += k k >>= 1 return x + 1 N = int(input()) ans_list = [0] * N query = [] for _ in range(N): xn, yn, xp, yp = map(int, input().split()) query.append((-xn, -yn, xp, yp)) for p, q in ((2, 3), (0, 3), (0, 1), (2, 1)): bit_pp = Bit(K+1) bit_pp.add(K+1, 1) y_pp = [0] * (K+2) y_pp[0] = 10**5 for ii in range(N): xp, yp = query[ii][p], query[ii][q] ans = 0 if yp > y_pp[xp]: j = bit_pp.sum(xp) x_nxt = bit_pp.lower_bound(j + 1) if yp > y_pp[x_nxt]: if y_pp[xp] == 0: bit_pp.add(xp, 1) y_cur = y_pp[x_nxt] j += 1 else: y_cur = y_pp[xp] y_pp[xp] = yp x_cur = xp while True: x_prev = bit_pp.lower_bound(j-1) if yp <= y_pp[x_prev]: ans += (x_cur - x_prev) * (yp - y_cur) break else: ans += (x_cur - x_prev) * (yp - y_cur) j -= 1 bit_pp.add(x_prev, -1) y_cur = y_pp[x_prev] y_pp[x_prev] = 0 x_cur = x_prev ans_list[ii] += ans print(*ans_list, sep="\n") if __name__ == '__main__': main()