結果

問題 No.1898 Battle and Exchange
ユーザー ShirotsumeShirotsume
提出日時 2021-12-12 17:57:10
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,586 bytes
コンパイル時間 227 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 61,056 KB
最終ジャッジ日時 2024-04-26 19:43:19
合計ジャッジ時間 32,133 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,880 KB
testcase_01 AC 31 ms
10,752 KB
testcase_02 AC 31 ms
10,752 KB
testcase_03 AC 32 ms
10,752 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 32 ms
10,880 KB
testcase_12 AC 48 ms
11,008 KB
testcase_13 AC 31 ms
10,752 KB
testcase_14 AC 44 ms
10,880 KB
testcase_15 AC 32 ms
10,880 KB
testcase_16 AC 36 ms
11,008 KB
testcase_17 AC 246 ms
12,928 KB
testcase_18 AC 1,035 ms
20,096 KB
testcase_19 AC 1,868 ms
24,576 KB
testcase_20 AC 2,204 ms
25,984 KB
testcase_21 AC 4,986 ms
47,872 KB
testcase_22 AC 32 ms
10,880 KB
testcase_23 AC 36 ms
11,136 KB
testcase_24 AC 36 ms
11,008 KB
testcase_25 AC 40 ms
11,008 KB
testcase_26 AC 31 ms
10,752 KB
testcase_27 AC 70 ms
11,136 KB
testcase_28 AC 82 ms
11,392 KB
testcase_29 AC 182 ms
12,160 KB
testcase_30 AC 43 ms
10,880 KB
testcase_31 AC 34 ms
11,008 KB
testcase_32 AC 1,277 ms
24,192 KB
testcase_33 WA -
testcase_34 AC 879 ms
21,888 KB
testcase_35 AC 1,704 ms
28,544 KB
testcase_36 WA -
testcase_37 AC 650 ms
16,128 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))
        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