結果

問題 No.1995 CHIKA Road
ユーザー titiatitia
提出日時 2022-07-01 21:59:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,223 bytes
コンパイル時間 229 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 74,408 KB
最終ジャッジ日時 2024-05-04 16:25:23
合計ジャッジ時間 5,938 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,880 KB
testcase_01 AC 32 ms
10,752 KB
testcase_02 AC 31 ms
10,752 KB
testcase_03 AC 31 ms
10,752 KB
testcase_04 AC 31 ms
10,752 KB
testcase_05 AC 33 ms
10,880 KB
testcase_06 AC 166 ms
14,472 KB
testcase_07 AC 566 ms
23,472 KB
testcase_08 AC 33 ms
10,880 KB
testcase_09 AC 33 ms
10,752 KB
testcase_10 AC 676 ms
28,416 KB
testcase_11 TLE -
testcase_12 AC 1,938 ms
53,656 KB
testcase_13 AC 900 ms
30,472 KB
testcase_14 AC 930 ms
31,004 KB
testcase_15 TLE -
testcase_16 AC 275 ms
16,432 KB
testcase_17 AC 1,247 ms
35,444 KB
testcase_18 TLE -
testcase_19 TLE -
testcase_20 AC 1,131 ms
33,384 KB
testcase_21 AC 994 ms
31,492 KB
testcase_22 TLE -
testcase_23 AC 587 ms
23,848 KB
testcase_24 AC 1,753 ms
47,152 KB
testcase_25 AC 330 ms
17,904 KB
testcase_26 AC 680 ms
27,016 KB
testcase_27 AC 1,693 ms
46,152 KB
testcase_28 AC 982 ms
31,592 KB
testcase_29 TLE -
testcase_30 AC 313 ms
17,748 KB
testcase_31 AC 159 ms
14,360 KB
testcase_32 AC 412 ms
20,324 KB
testcase_33 AC 1,624 ms
45,548 KB
testcase_34 AC 173 ms
14,672 KB
testcase_35 AC 635 ms
24,588 KB
testcase_36 AC 739 ms
27,900 KB
testcase_37 AC 1,921 ms
49,552 KB
testcase_38 AC 1,344 ms
38,300 KB
testcase_39 AC 150 ms
14,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0