結果
| 問題 | 
                            No.859 路線A、路線B、路線C
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 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 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 11 WA * 1 | 
ソースコード
###ダイクストラ###
def daikusutora(N, G, s):
	  dist = [INF] * N
	  que = [(0, s)]
	  dist[s] = 0
	  while que:
	  	  c, v = heappop(que)
	  	  if dist[v] < c:
	  	  	  continue
	  	  for t, cost in G[v]:
	  	  	  if dist[v] + cost < dist[t]:
	  	  	  	  dist[t] = dist[v] + cost
	  	  	  	  heappush(que, (dist[t], t))
	  return dist
import sys
from sys import stdin
from fractions import Fraction
import math
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque, defaultdict
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement, permutations
from bisect import bisect, bisect_left, bisect_right
from functools import reduce, lru_cache
from decimal import Decimal, getcontext, ROUND_HALF_UP
def 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 d
def rotate(table):
   	  n_fild = []
   	  for x in zip(*table[::-1]):
   	  	  n_fild.append(x)
   	  return n_fild
sys.setrecursionlimit(10 ** 7)
INF = float('inf')
MOD = 10 ** 9 + 7
MOD2 = 998244353
alpa = '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()