結果

問題 No.1898 Battle and Exchange
ユーザー ShirotsumeShirotsume
提出日時 2021-12-20 03:17:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,705 bytes
コンパイル時間 255 ms
コンパイル使用メモリ 81,636 KB
実行使用メモリ 106,824 KB
最終ジャッジ日時 2023-10-22 04:33:42
合計ジャッジ時間 19,493 ms
ジャッジサーバーID
(参考情報)
judge10 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,424 KB
testcase_01 AC 42 ms
53,424 KB
testcase_02 AC 42 ms
53,424 KB
testcase_03 WA -
testcase_04 AC 109 ms
76,076 KB
testcase_05 AC 119 ms
76,096 KB
testcase_06 AC 129 ms
76,260 KB
testcase_07 WA -
testcase_08 AC 107 ms
75,976 KB
testcase_09 AC 309 ms
78,820 KB
testcase_10 AC 44 ms
55,472 KB
testcase_11 AC 65 ms
68,176 KB
testcase_12 AC 125 ms
77,112 KB
testcase_13 AC 42 ms
53,424 KB
testcase_14 AC 131 ms
77,004 KB
testcase_15 AC 46 ms
55,472 KB
testcase_16 AC 119 ms
76,176 KB
testcase_17 AC 469 ms
80,420 KB
testcase_18 AC 1,692 ms
96,564 KB
testcase_19 AC 2,502 ms
105,048 KB
testcase_20 AC 2,587 ms
106,824 KB
testcase_21 TLE -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq
def solve(n, m, graph, abc):
    for i in range(n):
        abc[i].sort(reverse = True)
    def check(x):
        #A = x, B = 1, C = 1で突破できる?
        a = x
        b = 1
        c = 1
        q = []
        good = [False] * n
        visit = [False] * n
        if sum(abc[0]) >= a + b + c:
            return False
        b = abc[0][0]
        good[0] = True
        visit[0] = True
        for to in graph[0]:
            visit[to] = True
            heapq.heappush(q, (sum(abc[to]), to))
        
        while q:
            nowsum, now = heapq.heappop(q)
            if nowsum < a + b + c:
                good[now] = True
            else:
                continue
            a, b, c = sorted([a, b, c], reverse = True)
            b = max(b, abc[0][1])
            c = max(c, abc[0][0])
            a, b, c = sorted([a, b, c],reverse = True)
            b = max(b, abc[now][1])
            c = max(c, abc[now][0])
        
                
            for to in graph[now]:
                if not visit[to]:
                    visit[to] = True
                    heapq.heappush(q, (sum(abc[to]), to))
        if good[n - 1]:
            return True
        else:
            return False
    ok = 10 ** 15
    ng = 1
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if check(mid):
            ok = mid
        else:
            ng = mid
    return ok, 1, 1

n, m = map(int,input().split())
graph = [[] for _ in range(n)]

for _ in range(m):
    u, v = map(int,input().split())
    u -= 1
    v -= 1
    graph[u].append(v)
    graph[v].append(u)

abc = [list(map(int,input().split())) for _ in range(n)]

a, b, c = solve(n, m, graph, abc)

print(a, b, c)
0