結果

問題 No.1898 Battle and Exchange
ユーザー ShirotsumeShirotsume
提出日時 2021-12-20 03:23:11
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,705 bytes
コンパイル時間 327 ms
コンパイル使用メモリ 81,876 KB
実行使用メモリ 154,320 KB
最終ジャッジ日時 2023-10-22 04:34:43
合計ジャッジ時間 23,431 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,588 KB
testcase_01 AC 37 ms
53,588 KB
testcase_02 AC 38 ms
53,588 KB
testcase_03 WA -
testcase_04 AC 96 ms
76,284 KB
testcase_05 AC 105 ms
76,304 KB
testcase_06 AC 111 ms
76,476 KB
testcase_07 WA -
testcase_08 AC 93 ms
76,180 KB
testcase_09 AC 278 ms
79,028 KB
testcase_10 AC 41 ms
55,636 KB
testcase_11 AC 59 ms
68,372 KB
testcase_12 AC 111 ms
77,316 KB
testcase_13 AC 39 ms
53,588 KB
testcase_14 AC 119 ms
77,212 KB
testcase_15 AC 43 ms
55,636 KB
testcase_16 AC 110 ms
76,384 KB
testcase_17 AC 344 ms
80,628 KB
testcase_18 AC 1,254 ms
96,768 KB
testcase_19 AC 1,969 ms
105,252 KB
testcase_20 AC 2,065 ms
106,972 KB
testcase_21 TLE -
testcase_22 AC 57 ms
68,436 KB
testcase_23 AC 97 ms
76,288 KB
testcase_24 AC 89 ms
76,120 KB
testcase_25 AC 110 ms
77,224 KB
testcase_26 AC 46 ms
61,292 KB
testcase_27 AC 109 ms
77,188 KB
testcase_28 AC 111 ms
77,188 KB
testcase_29 AC 137 ms
77,972 KB
testcase_30 AC 105 ms
77,288 KB
testcase_31 AC 76 ms
75,704 KB
testcase_32 AC 658 ms
102,124 KB
testcase_33 AC 1,454 ms
124,776 KB
testcase_34 AC 580 ms
99,012 KB
testcase_35 AC 923 ms
111,568 KB
testcase_36 WA -
testcase_37 AC 638 ms
94,804 KB
testcase_38 TLE -
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