結果

問題 No.1382 Travel in Mitaru city
ユーザー vwxyzvwxyz
提出日時 2023-11-30 12:12:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 742 ms / 2,000 ms
コード長 1,348 bytes
コンパイル時間 757 ms
コンパイル使用メモリ 12,160 KB
実行使用メモリ 39,924 KB
最終ジャッジ日時 2023-11-30 12:12:59
合計ジャッジ時間 32,877 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
11,136 KB
testcase_01 AC 37 ms
11,136 KB
testcase_02 AC 36 ms
11,136 KB
testcase_03 AC 36 ms
11,136 KB
testcase_04 AC 36 ms
11,136 KB
testcase_05 AC 37 ms
11,136 KB
testcase_06 AC 257 ms
20,608 KB
testcase_07 AC 197 ms
18,304 KB
testcase_08 AC 118 ms
15,104 KB
testcase_09 AC 255 ms
21,376 KB
testcase_10 AC 266 ms
20,992 KB
testcase_11 AC 435 ms
26,444 KB
testcase_12 AC 448 ms
26,696 KB
testcase_13 AC 501 ms
27,340 KB
testcase_14 AC 408 ms
25,672 KB
testcase_15 AC 425 ms
25,932 KB
testcase_16 AC 712 ms
34,676 KB
testcase_17 AC 662 ms
34,676 KB
testcase_18 AC 676 ms
34,676 KB
testcase_19 AC 675 ms
34,420 KB
testcase_20 AC 680 ms
34,672 KB
testcase_21 AC 671 ms
34,164 KB
testcase_22 AC 666 ms
34,036 KB
testcase_23 AC 696 ms
34,416 KB
testcase_24 AC 709 ms
34,676 KB
testcase_25 AC 691 ms
34,160 KB
testcase_26 AC 697 ms
33,920 KB
testcase_27 AC 712 ms
33,948 KB
testcase_28 AC 742 ms
33,924 KB
testcase_29 AC 709 ms
33,924 KB
testcase_30 AC 738 ms
33,924 KB
testcase_31 AC 383 ms
29,416 KB
testcase_32 AC 463 ms
33,252 KB
testcase_33 AC 430 ms
31,588 KB
testcase_34 AC 289 ms
25,236 KB
testcase_35 AC 200 ms
20,672 KB
testcase_36 AC 304 ms
29,664 KB
testcase_37 AC 81 ms
14,080 KB
testcase_38 AC 337 ms
31,720 KB
testcase_39 AC 110 ms
16,332 KB
testcase_40 AC 259 ms
26,536 KB
testcase_41 AC 277 ms
28,360 KB
testcase_42 AC 344 ms
32,024 KB
testcase_43 AC 295 ms
29,184 KB
testcase_44 AC 136 ms
18,384 KB
testcase_45 AC 270 ms
27,524 KB
testcase_46 AC 181 ms
18,936 KB
testcase_47 AC 669 ms
37,828 KB
testcase_48 AC 441 ms
29,932 KB
testcase_49 AC 736 ms
39,924 KB
testcase_50 AC 312 ms
24,180 KB
testcase_51 AC 393 ms
30,136 KB
testcase_52 AC 478 ms
33,548 KB
testcase_53 AC 125 ms
16,384 KB
testcase_54 AC 232 ms
21,512 KB
testcase_55 AC 440 ms
32,696 KB
testcase_56 AC 163 ms
18,568 KB
testcase_57 AC 286 ms
25,660 KB
testcase_58 AC 77 ms
13,696 KB
testcase_59 AC 184 ms
18,296 KB
testcase_60 AC 432 ms
32,092 KB
testcase_61 AC 47 ms
11,264 KB
testcase_62 AC 37 ms
11,136 KB
testcase_63 AC 82 ms
11,904 KB
testcase_64 AC 52 ms
11,392 KB
testcase_65 AC 37 ms
11,136 KB
testcase_66 AC 43 ms
11,264 KB
testcase_67 AC 46 ms
11,264 KB
testcase_68 AC 53 ms
11,392 KB
testcase_69 AC 43 ms
11,264 KB
testcase_70 AC 58 ms
11,520 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