結果

問題 No.1382 Travel in Mitaru city
ユーザー marroncastlemarroncastle
提出日時 2021-02-07 22:42:40
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,455 bytes
コンパイル時間 1,304 ms
コンパイル使用メモリ 87,100 KB
実行使用メモリ 105,028 KB
最終ジャッジ日時 2023-09-17 23:06:15
合計ジャッジ時間 19,248 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
71,372 KB
testcase_01 AC 75 ms
71,400 KB
testcase_02 AC 76 ms
71,428 KB
testcase_03 AC 76 ms
71,388 KB
testcase_04 AC 76 ms
71,256 KB
testcase_05 WA -
testcase_06 AC 206 ms
82,912 KB
testcase_07 AC 203 ms
82,644 KB
testcase_08 AC 181 ms
80,892 KB
testcase_09 AC 213 ms
83,412 KB
testcase_10 AC 205 ms
83,768 KB
testcase_11 WA -
testcase_12 AC 305 ms
90,676 KB
testcase_13 AC 318 ms
90,820 KB
testcase_14 AC 281 ms
89,888 KB
testcase_15 AC 300 ms
89,880 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 371 ms
96,208 KB
testcase_19 WA -
testcase_20 AC 370 ms
96,012 KB
testcase_21 AC 381 ms
96,552 KB
testcase_22 AC 380 ms
96,440 KB
testcase_23 AC 381 ms
96,264 KB
testcase_24 AC 371 ms
96,332 KB
testcase_25 AC 380 ms
96,312 KB
testcase_26 AC 330 ms
95,920 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 339 ms
95,584 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 168 ms
92,772 KB
testcase_37 AC 108 ms
79,528 KB
testcase_38 AC 177 ms
94,260 KB
testcase_39 AC 119 ms
82,500 KB
testcase_40 AC 154 ms
91,976 KB
testcase_41 AC 155 ms
91,528 KB
testcase_42 AC 168 ms
94,528 KB
testcase_43 AC 161 ms
92,988 KB
testcase_44 AC 123 ms
84,556 KB
testcase_45 AC 157 ms
91,508 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 AC 211 ms
95,656 KB
testcase_52 AC 229 ms
95,156 KB
testcase_53 AC 132 ms
82,376 KB
testcase_54 AC 158 ms
87,972 KB
testcase_55 AC 220 ms
95,176 KB
testcase_56 AC 137 ms
84,296 KB
testcase_57 AC 183 ms
91,776 KB
testcase_58 AC 118 ms
79,400 KB
testcase_59 AC 137 ms
84,264 KB
testcase_60 AC 215 ms
95,284 KB
testcase_61 WA -
testcase_62 AC 77 ms
71,340 KB
testcase_63 WA -
testcase_64 WA -
testcase_65 WA -
testcase_66 WA -
testcase_67 WA -
testcase_68 WA -
testcase_69 WA -
testcase_70 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from heapq import *
class Graph:
  def __init__(self, N, M=-1):
    self.V = N
    if M>=0: self.E = M
    self.edge = [[] for _ in range(self.V)]
    self.edge_rev = [[] for _ in range(self.V)]
    self.order = []
    self.to = [0]*self.V
    self.visited = [False]*self.V
    self.dp = [0]*self.V

  def add_edges(self, ind=1, bi=False, rev=False):
    for i in range(self.E):
      a,b = map(int, input().split())
      a -= ind; b -= ind
      self.edge[a].append(b)
      if rev: self.edge_rev[b].append(a)
      if not bi: self.to[b] += 1
      if bi: self.edge[b].append(a)

  def add_edge(self, a, b, dist=-1, bi=False, rev=False):
    if dist>=0:
      self.edge[a].append((dist, b))
      if rev: self.edge_rev[b].append((dist, a))
      if bi: self.edge[b].append((dist, a))
    else:
      self.edge[a].append(b)
      if rev: self.edge_rev[b].append(a)
      if bi: self.edge[b].append(a)
    if not bi: self.to[b] += 1

  def bfs(self, start):
    self.visited[start] = True
    d = [(-P[start], start)]
    heapify(d)
    ans = 0
    while len(d)>0:
      p,v = heappop(d)
      for w in self.edge[v]:
        if not self.visited[w]:
          if P[w]<-p: ans += 1
          else: P[w] = -p
          self.visited[w] = True
          heappush(d, (-P[w],w))
    return ans

N, M, S, T = map(int, input().split())
P = list(map(int, input().split()))
G = Graph(N,M)
G.add_edges(bi=True)
print(G.bfs(S-1))
0