結果

問題 No.1898 Battle and Exchange
ユーザー ShirotsumeShirotsume
提出日時 2021-12-20 03:04:36
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,690 bytes
コンパイル時間 647 ms
コンパイル使用メモリ 81,580 KB
実行使用メモリ 207,988 KB
最終ジャッジ日時 2023-10-22 04:32:56
合計ジャッジ時間 18,219 ms
ジャッジサーバーID
(参考情報)
judge10 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 41 ms
53,424 KB
testcase_02 AC 42 ms
53,424 KB
testcase_03 AC 43 ms
53,424 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 127 ms
76,136 KB
testcase_08 AC 107 ms
76,116 KB
testcase_09 AC 305 ms
78,928 KB
testcase_10 AC 43 ms
55,472 KB
testcase_11 AC 65 ms
68,192 KB
testcase_12 AC 123 ms
77,144 KB
testcase_13 AC 41 ms
53,424 KB
testcase_14 AC 133 ms
76,996 KB
testcase_15 AC 46 ms
55,472 KB
testcase_16 AC 116 ms
76,008 KB
testcase_17 AC 436 ms
80,428 KB
testcase_18 AC 1,565 ms
96,612 KB
testcase_19 AC 2,377 ms
105,212 KB
testcase_20 AC 2,401 ms
106,816 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][0])
            c = max(c, abc[0][1])
            a, b, c = sorted([a, b, c],reverse = True)
            b = max(b, abc[now][0])
            c = max(c, abc[now][1])
        
                
            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)]

print(*solve(n, m, graph, abc))


0