結果
問題 | No.1995 CHIKA Road |
ユーザー | tassei903 |
提出日時 | 2022-07-01 22:43:48 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,829 bytes |
コンパイル時間 | 208 ms |
コンパイル使用メモリ | 82,220 KB |
実行使用メモリ | 160,720 KB |
最終ジャッジ日時 | 2024-05-04 17:06:53 |
合計ジャッジ時間 | 10,889 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 36 ms
52,736 KB |
testcase_01 | AC | 35 ms
52,480 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 261 ms
124,288 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
ソースコード
import sys input = lambda :sys.stdin.readline()[:-1] ni = lambda :int(input()) na = lambda :list(map(int,input().split())) yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES") no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO") ####################################################################### class DualSegmentTree: def __init__(self, size, f, default): self.n = (size-1).bit_length() self.size = 1<<self.n self.default = default self.lazy = [default]*(self.size*2) self.f = f def propagate(self, k): lazy = self.lazy if lazy[k] != self.default: lazy[2*k] = self.f(lazy[2*k], lazy[k]) lazy[2*k+1] = self.f(lazy[2*k+1], lazy[k]) lazy[k] = self.default def thrust(self, k): for i in range(self.n,0,-1): self.propagate(k>>i) def update(self, a, b, x): a += self.size b += self.size-1 self.thrust(a) self.thrust(b) l = a r = b + 1 lazy = self.lazy while l < r: if l & 1: lazy[l] = self.f(lazy[l], x) l += 1 if r & 1: r -= 1 lazy[r] = self.f(lazy[r], x) l >>= 1 r >>= 1 def get(self, k): k += self.size self.thrust(k) return self.lazy[k] n,m = na() g = [na() for i in range(m)] s = set() for i in range(m): s.add(g[i][0]) s.add(g[i][1]) d = {x:i for i, x in enumerate(sorted(s))} for i in range(m): g[i] = [d[g[i][0]],d[g[i][1]]] k = len(s) inf = float("inf") st = DualSegmentTree(k+1,max,-inf) st.update(0,k+1,0) for i in range(m): l,r = g[i] x = st.get(l) st.update(r,k+1,x + 1) print(2*(n-1)-st.get(k))