結果
問題 | No.859 路線A、路線B、路線C |
ユーザー | McGregorsh |
提出日時 | 2023-07-10 20:50:50 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,983 bytes |
コンパイル時間 | 438 ms |
コンパイル使用メモリ | 82,284 KB |
実行使用メモリ | 88,584 KB |
最終ジャッジ日時 | 2024-09-12 23:50:38 |
合計ジャッジ時間 | 3,383 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 138 ms
88,404 KB |
testcase_01 | AC | 139 ms
88,152 KB |
testcase_02 | AC | 144 ms
88,180 KB |
testcase_03 | AC | 142 ms
88,100 KB |
testcase_04 | AC | 140 ms
88,452 KB |
testcase_05 | AC | 140 ms
88,460 KB |
testcase_06 | AC | 138 ms
88,388 KB |
testcase_07 | AC | 137 ms
88,244 KB |
testcase_08 | AC | 140 ms
88,472 KB |
testcase_09 | AC | 144 ms
88,244 KB |
testcase_10 | AC | 141 ms
88,368 KB |
testcase_11 | WA | - |
testcase_12 | AC | 142 ms
88,392 KB |
testcase_13 | AC | 146 ms
88,464 KB |
testcase_14 | AC | 144 ms
88,460 KB |
ソースコード
###ダイクストラ###def daikusutora(N, G, s):dist = [INF] * Nque = [(0, s)]dist[s] = 0while que:c, v = heappop(que)if dist[v] < c:continuefor t, cost in G[v]:if dist[v] + cost < dist[t]:dist[t] = dist[v] + costheappush(que, (dist[t], t))return distimport sysfrom sys import stdinfrom fractions import Fractionimport mathfrom math import ceil, floor, sqrt, pi, factorial, gcdfrom copy import deepcopyfrom collections import Counter, deque, defaultdictfrom heapq import heapify, heappop, heappushfrom itertools import accumulate, product, combinations, combinations_with_replacement, permutationsfrom bisect import bisect, bisect_left, bisect_rightfrom functools import reduce, lru_cachefrom decimal import Decimal, getcontext, ROUND_HALF_UPdef i_input(): return int(stdin.readline())def i_map(): return map(int, stdin.readline().split())def i_list(): return list(i_map())def s_input(): return stdin.readline()[:-1]def s_map(): return s_input().split()def s_list(): return list(s_map())def lcm(a, b): return a * b // gcd(a, b)def get_distance(x1, y1, x2, y2):d = sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)return ddef rotate(table):n_fild = []for x in zip(*table[::-1]):n_fild.append(x)return n_fildsys.setrecursionlimit(10 ** 7)INF = float('inf')MOD = 10 ** 9 + 7MOD2 = 998244353alpa = 'abcdefghijklmnopqrstuvwxyz'ALPA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'def main():x, y, z = i_map()s1, t1 = s_map()t1 = int(t1)s2, t2 = s_map()t2 = int(t2)G = [[] for i in range(8)]G[0].append([1, x-1])G[1].append([0, x-1])G[2].append([3, y-1])G[3].append([2, y-1])G[4].append([5, z-1])G[5].append([4, z-1])G[0].append([2, 1])G[2].append([0, 1])G[0].append([4, 1])G[4].append([0, 1])G[2].append([4, 1])G[4].append([2, 1])G[1].append([3, 1])G[3].append([1, 1])G[1].append([5, 1])G[5].append([1, 1])G[3].append([5, 1])G[5].append([3, 1])if s1 == 'A':G[6].append([0, t1-1])G[0].append([6, t1-1])G[6].append([1, x-t1])G[1].append([6, x-t1])elif s1 == 'B':G[6].append([2, t1-1])G[2].append([6, t1-1])G[6].append([3, y-t1])G[3].append([6, y-t1])else:G[6].append([4, t1-1])G[4].append([6, t1-1])G[6].append([5, z-t1])G[5].append([6, z-t1])if s2 == 'A':G[7].append([0, t2-1])G[0].append([7, t2-1])G[7].append([1, x-t2])G[1].append([7, x-t2])elif s2 == 'B':G[7].append([2, t2-1])G[2].append([7, t2-1])G[7].append([3, y-t2])G[3].append([7, y-t2])else:G[7].append([4, t2-1])G[4].append([7, t2-1])G[7].append([5, z-t2])G[5].append([7, z-t2])ans = daikusutora(8, G, 6)print(ans[-1])if __name__ == '__main__':main()