結果

問題 No.1382 Travel in Mitaru city
ユーザー vwxyzvwxyz
提出日時 2023-11-30 12:12:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 465 ms / 2,000 ms
コード長 1,348 bytes
コンパイル時間 346 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 111,344 KB
最終ジャッジ日時 2023-11-30 12:13:08
合計ジャッジ時間 23,460 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
88,932 KB
testcase_01 AC 138 ms
88,932 KB
testcase_02 AC 139 ms
88,932 KB
testcase_03 AC 140 ms
88,932 KB
testcase_04 AC 140 ms
88,932 KB
testcase_05 AC 142 ms
88,932 KB
testcase_06 AC 241 ms
94,564 KB
testcase_07 AC 234 ms
93,796 KB
testcase_08 AC 223 ms
92,516 KB
testcase_09 AC 250 ms
95,204 KB
testcase_10 AC 252 ms
94,820 KB
testcase_11 AC 313 ms
101,092 KB
testcase_12 AC 341 ms
101,092 KB
testcase_13 AC 348 ms
101,092 KB
testcase_14 AC 345 ms
101,092 KB
testcase_15 AC 313 ms
101,092 KB
testcase_16 AC 395 ms
108,388 KB
testcase_17 AC 391 ms
108,388 KB
testcase_18 AC 395 ms
108,388 KB
testcase_19 AC 390 ms
108,388 KB
testcase_20 AC 389 ms
108,260 KB
testcase_21 AC 422 ms
108,388 KB
testcase_22 AC 424 ms
108,388 KB
testcase_23 AC 416 ms
108,388 KB
testcase_24 AC 417 ms
108,388 KB
testcase_25 AC 386 ms
108,388 KB
testcase_26 AC 440 ms
108,388 KB
testcase_27 AC 440 ms
108,260 KB
testcase_28 AC 408 ms
108,388 KB
testcase_29 AC 409 ms
108,388 KB
testcase_30 AC 411 ms
108,388 KB
testcase_31 AC 266 ms
105,572 KB
testcase_32 AC 290 ms
108,004 KB
testcase_33 AC 278 ms
107,620 KB
testcase_34 AC 242 ms
100,964 KB
testcase_35 AC 248 ms
98,148 KB
testcase_36 AC 223 ms
105,700 KB
testcase_37 AC 170 ms
92,132 KB
testcase_38 AC 229 ms
107,748 KB
testcase_39 AC 184 ms
94,308 KB
testcase_40 AC 222 ms
102,372 KB
testcase_41 AC 220 ms
104,036 KB
testcase_42 AC 239 ms
107,876 KB
testcase_43 AC 229 ms
105,572 KB
testcase_44 AC 185 ms
96,484 KB
testcase_45 AC 225 ms
103,908 KB
testcase_46 AC 256 ms
96,100 KB
testcase_47 AC 438 ms
109,844 KB
testcase_48 AC 366 ms
104,920 KB
testcase_49 AC 465 ms
111,344 KB
testcase_50 AC 295 ms
100,452 KB
testcase_51 AC 263 ms
105,316 KB
testcase_52 AC 287 ms
107,492 KB
testcase_53 AC 198 ms
94,180 KB
testcase_54 AC 217 ms
98,788 KB
testcase_55 AC 277 ms
107,364 KB
testcase_56 AC 225 ms
95,972 KB
testcase_57 AC 244 ms
101,860 KB
testcase_58 AC 178 ms
91,876 KB
testcase_59 AC 199 ms
96,100 KB
testcase_60 AC 296 ms
107,236 KB
testcase_61 AC 148 ms
89,828 KB
testcase_62 AC 138 ms
88,932 KB
testcase_63 AC 158 ms
90,340 KB
testcase_64 AC 146 ms
89,828 KB
testcase_65 AC 141 ms
89,316 KB
testcase_66 AC 154 ms
89,828 KB
testcase_67 AC 164 ms
89,828 KB
testcase_68 AC 153 ms
89,828 KB
testcase_69 AC 168 ms
89,828 KB
testcase_70 AC 179 ms
89,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
import copy
import decimal
import fractions
import heapq
import itertools
import math
import random
import sys
import time
from collections import Counter,deque,defaultdict
from functools import lru_cache,reduce
from heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_max
def _heappush_max(heap,item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappushpop_max(heap, item):
    if heap and item < heap[0]:
        item, heap[0] = heap[0], item
        heapq._siftup_max(heap, 0)
    return item
from math import gcd as GCD
read=sys.stdin.read
readline=sys.stdin.readline
readlines=sys.stdin.readlines
write=sys.stdout.write
#import pypyjit
#pypyjit.set_param('max_unroll_recursion=-1')
#sys.set_int_max_str_digits(10**9)

N,M,S,T=map(int,readline().split())
S-=1;T-=1
P=list(map(int,readline().split()))
for i in range(N):
    P[i]-=1
graph=[[] for x in range(N)]
for m in range(M):
    a,b=map(int,readline().split())
    a-=1;b-=1
    graph[a].append(b)
    graph[b].append(a)
queue=[(P[S],S)]
seen=[False]*N
seen[S]=True
Y=[-1]*N
y=0
x=P[S]
while queue:
    p,a=_heappop_max(queue)
    if x>P[a]:
        x=P[a]
        y+=1
    Y[a]=y
    for b in graph[a]:
        if seen[b]:
            continue
        _heappush_max(queue,(P[b],b))
        seen[b]=True
ans=max(Y)
print(ans)
0