結果

問題 No.2220 Range Insert & Point Mex
ユーザー flygonflygon
提出日時 2023-02-17 23:22:00
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,888 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 86,920 KB
実行使用メモリ 124,180 KB
最終ジャッジ日時 2023-09-26 20:45:46
合計ジャッジ時間 16,348 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
85,020 KB
testcase_01 AC 104 ms
84,872 KB
testcase_02 AC 104 ms
85,004 KB
testcase_03 AC 103 ms
84,984 KB
testcase_04 AC 103 ms
84,760 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 108 ms
84,972 KB
testcase_11 AC 105 ms
85,020 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 450 ms
108,096 KB
testcase_21 AC 453 ms
108,172 KB
testcase_22 AC 460 ms
108,244 KB
testcase_23 AC 426 ms
112,244 KB
testcase_24 AC 381 ms
105,080 KB
testcase_25 AC 345 ms
100,544 KB
testcase_26 AC 301 ms
113,832 KB
testcase_27 AC 257 ms
100,980 KB
testcase_28 AC 143 ms
102,504 KB
testcase_29 AC 199 ms
101,220 KB
testcase_30 AC 144 ms
103,152 KB
testcase_31 AC 289 ms
120,040 KB
testcase_32 AC 318 ms
111,572 KB
testcase_33 AC 344 ms
113,060 KB
testcase_34 AC 609 ms
124,180 KB
testcase_35 AC 630 ms
122,728 KB
testcase_36 AC 602 ms
123,672 KB
testcase_37 AC 629 ms
122,788 KB
testcase_38 AC 361 ms
118,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(5*10**5)
input = sys.stdin.readline
from collections import defaultdict, deque, Counter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
from math import gcd

n= int(input())
lr = [list(map(int,input().split())) for i in range(n)]
q = int(input())
x = list(map(int,input().split()))
lr.sort(key = lambda x: (x[2], x[0]))
lr = lr[::-1]
INF= 10**10
seg_len = 1<<19 # > 5*(10**5)
seg = [INF]*(2*seg_len)

for i in range(q):
  seg[i+seg_len] = i

for i in range(seg_len)[::-1]:
  seg[i] = min(seg[i*2], seg[i*2+1]) 

def update(pos):
  pos += seg_len
  seg[pos] = INF 
  while True: 
    pos >>= 1 
    if not pos: break 
    seg[pos] = min(seg[pos<<1],  seg[pos<<1|1])

def get_query(l,r):
  l += seg_len; r += seg_len
  res = INF
  while l < r: 
    if l & 1: 
      res = min(res, seg[l])
      l += 1 
    if r & 1: 
      r -= 1 
      res = min(res, seg[r]) 
    l >>= 1; r >>= 1
  return res


ans = [-1]*q
for num in range(n+10):
  use = []
  mx = 0
  while lr and lr[-1][2] == num:
    l,r,_ = lr.pop()
    tl = bisect_left(x,l)
    tr = bisect_right(x,r)
    mx = max(mx, tr)
    use.append([tl,tr])
  if not use:
    break
  ss = set()
  last = 0
  for i in range(len(use)):
    tl,tr = use[i]
    if tl < last: continue
    last = max(last, tr)
    if i == 0:
      tmp = get_query(0, tl)
      while tmp != INF:
        update(tmp)
        ss.add(tmp)
        ans[tmp] = num
        tmp = get_query(0,tl)
    if i != 0:
      prer = use[i-1][1]
      tmp = get_query(prer, tl)
      while tmp != INF:
        update(tmp)
        ss.add(tmp)
        ans[tmp] = num
        tmp = get_query(prer,tl)
  tmp = get_query(mx, seg_len)
  while tmp != INF:
    update(tmp)
    ss.add(tmp)
    ans[tmp] = num 
    tmp = get_query(mx, seg_len)
for i in range(q):
  if ans[i] == -1:
    ans[i] = num

print(*ans, sep = "\n")

0