結果

問題 No.1898 Battle and Exchange
ユーザー ShirotsumeShirotsume
提出日時 2021-12-06 19:14:48
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,586 bytes
コンパイル時間 256 ms
コンパイル使用メモリ 81,868 KB
実行使用メモリ 232,192 KB
最終ジャッジ日時 2023-10-22 04:30:12
合計ジャッジ時間 49,622 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
53,592 KB
testcase_01 AC 36 ms
53,592 KB
testcase_02 AC 37 ms
53,592 KB
testcase_03 AC 37 ms
53,592 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 48 ms
63,996 KB
testcase_12 AC 98 ms
76,520 KB
testcase_13 AC 37 ms
53,600 KB
testcase_14 AC 93 ms
76,468 KB
testcase_15 AC 38 ms
53,600 KB
testcase_16 AC 82 ms
75,828 KB
testcase_17 AC 212 ms
78,732 KB
testcase_18 AC 515 ms
89,152 KB
testcase_19 AC 878 ms
93,948 KB
testcase_20 AC 1,037 ms
96,684 KB
testcase_21 AC 2,390 ms
120,464 KB
testcase_22 AC 50 ms
64,128 KB
testcase_23 AC 83 ms
75,824 KB
testcase_24 AC 73 ms
74,032 KB
testcase_25 AC 97 ms
76,496 KB
testcase_26 AC 41 ms
59,044 KB
testcase_27 AC 103 ms
77,080 KB
testcase_28 AC 103 ms
77,092 KB
testcase_29 AC 118 ms
77,364 KB
testcase_30 AC 94 ms
76,532 KB
testcase_31 AC 54 ms
66,248 KB
testcase_32 AC 347 ms
95,220 KB
testcase_33 WA -
testcase_34 AC 276 ms
89,528 KB
testcase_35 AC 461 ms
100,752 KB
testcase_36 WA -
testcase_37 AC 315 ms
85,184 KB
testcase_38 AC 3,269 ms
215,424 KB
testcase_39 AC 2,089 ms
166,648 KB
testcase_40 AC 3,536 ms
232,192 KB
testcase_41 AC 2,450 ms
177,992 KB
testcase_42 AC 177 ms
78,184 KB
testcase_43 AC 1,903 ms
122,160 KB
testcase_44 AC 64 ms
70,644 KB
testcase_45 AC 222 ms
80,016 KB
testcase_46 AC 737 ms
95,600 KB
testcase_47 AC 197 ms
78,804 KB
testcase_48 AC 312 ms
83,768 KB
testcase_49 AC 129 ms
77,152 KB
testcase_50 AC 119 ms
77,096 KB
testcase_51 AC 127 ms
77,096 KB
testcase_52 AC 120 ms
77,360 KB
testcase_53 AC 295 ms
82,092 KB
testcase_54 AC 226 ms
81,448 KB
testcase_55 AC 331 ms
85,188 KB
testcase_56 AC 369 ms
85,144 KB
testcase_57 WA -
testcase_58 AC 3,513 ms
134,820 KB
testcase_59 AC 3,427 ms
134,100 KB
testcase_60 AC 2,998 ms
129,312 KB
権限があれば一括ダウンロードができます

ソースコード

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))
        if not q:
            return False
        else:
            c = max(c, abc[0][1])
        
        while q:
            nowsum, now = heapq.heappop(q)
            if nowsum < a + b + c:
                good[now] = True
            if b > c:
                b, c = c, b
            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 = 3 * 10 ** 9
    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