結果

問題 No.1898 Battle and Exchange
ユーザー polylogKpolylogK
提出日時 2021-12-23 17:45:10
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,665 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 11,908 KB
実行使用メモリ 59,280 KB
最終ジャッジ日時 2023-10-22 04:37:36
合計ジャッジ時間 24,359 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,288 KB
testcase_01 AC 26 ms
10,288 KB
testcase_02 AC 25 ms
10,288 KB
testcase_03 WA -
testcase_04 AC 29 ms
10,328 KB
testcase_05 AC 29 ms
10,320 KB
testcase_06 AC 37 ms
10,416 KB
testcase_07 WA -
testcase_08 AC 31 ms
10,304 KB
testcase_09 AC 111 ms
12,800 KB
testcase_10 AC 27 ms
10,288 KB
testcase_11 AC 28 ms
10,292 KB
testcase_12 AC 39 ms
10,460 KB
testcase_13 AC 27 ms
10,288 KB
testcase_14 AC 35 ms
10,408 KB
testcase_15 AC 27 ms
10,288 KB
testcase_16 AC 30 ms
10,324 KB
testcase_17 AC 109 ms
12,488 KB
testcase_18 AC 499 ms
19,436 KB
testcase_19 AC 1,018 ms
23,868 KB
testcase_20 AC 546 ms
25,100 KB
testcase_21 AC 1,940 ms
47,144 KB
testcase_22 AC 28 ms
10,292 KB
testcase_23 AC 30 ms
10,324 KB
testcase_24 AC 29 ms
10,324 KB
testcase_25 AC 34 ms
10,384 KB
testcase_26 AC 26 ms
10,292 KB
testcase_27 AC 53 ms
10,676 KB
testcase_28 AC 64 ms
10,796 KB
testcase_29 AC 135 ms
11,316 KB
testcase_30 AC 38 ms
10,404 KB
testcase_31 AC 28 ms
10,304 KB
testcase_32 AC 1,059 ms
23,652 KB
testcase_33 AC 2,024 ms
33,772 KB
testcase_34 AC 795 ms
21,284 KB
testcase_35 AC 1,304 ms
28,044 KB
testcase_36 WA -
testcase_37 AC 323 ms
15,488 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で突破できる?
        myabc = [x, 1, 1]
        q = []
        good = [False] * n
        visit = [False] * n
        if sum(abc[0]) >= sum(myabc):
            return False
        myabc[1] = 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 < sum(myabc):
                good[now] = True

                if now == n - 1:
                    return True
            else:
                return False

            myabc.sort(reverse=True)
            myabc[1] = max(myabc[1], abc[0][1])
            myabc[2] = max(myabc[2], abc[0][0])
            myabc[1] = max(myabc[1], abc[now][1])
            myabc[2] = max(myabc[2], abc[now][0])

            for to in graph[now]:
                if not visit[to]:
                    visit[to] = True
                    heapq.heappush(q, (sum(abc[to]), to))
        return good[n - 1]

    ok, ng = 3 * 10 ** 8, 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