結果
問題 | No.1995 CHIKA Road |
ユーザー | titia |
提出日時 | 2022-07-01 21:59:18 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 429 ms / 2,000 ms |
コード長 | 1,223 bytes |
コンパイル時間 | 304 ms |
コンパイル使用メモリ | 87,260 KB |
実行使用メモリ | 184,900 KB |
最終ジャッジ日時 | 2023-08-17 09:33:42 |
合計ジャッジ時間 | 10,177 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 65 ms
71,332 KB |
testcase_01 | AC | 65 ms
71,392 KB |
testcase_02 | AC | 65 ms
71,468 KB |
testcase_03 | AC | 64 ms
71,404 KB |
testcase_04 | AC | 65 ms
71,272 KB |
testcase_05 | AC | 74 ms
76,196 KB |
testcase_06 | AC | 141 ms
81,480 KB |
testcase_07 | AC | 184 ms
93,712 KB |
testcase_08 | AC | 77 ms
76,092 KB |
testcase_09 | AC | 75 ms
76,092 KB |
testcase_10 | AC | 169 ms
100,976 KB |
testcase_11 | AC | 429 ms
184,900 KB |
testcase_12 | AC | 281 ms
146,620 KB |
testcase_13 | AC | 213 ms
114,048 KB |
testcase_14 | AC | 219 ms
114,912 KB |
testcase_15 | AC | 389 ms
164,312 KB |
testcase_16 | AC | 150 ms
85,880 KB |
testcase_17 | AC | 256 ms
124,028 KB |
testcase_18 | AC | 336 ms
152,556 KB |
testcase_19 | AC | 343 ms
152,268 KB |
testcase_20 | AC | 238 ms
119,120 KB |
testcase_21 | AC | 232 ms
109,380 KB |
testcase_22 | AC | 328 ms
133,456 KB |
testcase_23 | AC | 182 ms
90,936 KB |
testcase_24 | AC | 304 ms
138,976 KB |
testcase_25 | AC | 156 ms
87,976 KB |
testcase_26 | AC | 201 ms
102,740 KB |
testcase_27 | AC | 297 ms
136,828 KB |
testcase_28 | AC | 233 ms
109,572 KB |
testcase_29 | AC | 328 ms
121,672 KB |
testcase_30 | AC | 154 ms
87,804 KB |
testcase_31 | AC | 136 ms
80,644 KB |
testcase_32 | AC | 168 ms
90,976 KB |
testcase_33 | AC | 293 ms
136,380 KB |
testcase_34 | AC | 140 ms
81,568 KB |
testcase_35 | AC | 190 ms
97,320 KB |
testcase_36 | AC | 209 ms
105,704 KB |
testcase_37 | AC | 322 ms
139,132 KB |
testcase_38 | AC | 266 ms
124,840 KB |
testcase_39 | AC | 136 ms
80,504 KB |
ソースコード
import sys input = sys.stdin.readline N,M=map(int,input().split()) EX=[list(map(int,input().split())) for i in range(M)] LIST=[] for x,y in EX: LIST.append(x) LIST.append(y) LIST=sorted(set(LIST)) D={LIST[i]:i for i in range(len(LIST))} E=[[] for i in range(len(LIST))] for x,y in EX: E[D[x]].append(D[y]) def seg_function(x,y): # Segment treeで扱うfunction return max(x,y) seg_el=1<<(len(LIST).bit_length()) # Segment treeの台の要素数 SEG=[0]*(2*seg_el) # 1-indexedなので、要素数2*seg_el.Segment treeの初期値で初期化 def update(n,x,seg_el): # A[n]をxへ更新 i=n+seg_el SEG[i]=x i>>=1 # 子ノードへ while i!=0: SEG[i]=seg_function(SEG[i*2],SEG[i*2+1]) i>>=1 def getvalues(l,r): # 区間[l,r)に関するseg_functionを調べる L=l+seg_el R=r+seg_el ANS=0 while L<R: if L & 1: ANS=seg_function(ANS , SEG[L]) L+=1 if R & 1: R-=1 ANS=seg_function(ANS , SEG[R]) L>>=1 R>>=1 return ANS for i in range(len(LIST)): k=getvalues(0,i+1) for to in E[i]: update(to,k+1,seg_el) ANS=SEG[1] print(N*2-2-ANS)