結果

問題 No.1898 Battle and Exchange
ユーザー ShirotsumeShirotsume
提出日時 2021-12-06 20:50:46
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,585 bytes
コンパイル時間 155 ms
コンパイル使用メモリ 81,644 KB
実行使用メモリ 173,824 KB
最終ジャッジ日時 2023-10-22 04:31:16
合計ジャッジ時間 39,866 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 40 ms
55,484 KB
testcase_02 AC 41 ms
55,484 KB
testcase_03 AC 39 ms
55,484 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 52 ms
61,536 KB
testcase_12 AC 84 ms
76,324 KB
testcase_13 AC 40 ms
55,484 KB
testcase_14 AC 80 ms
76,412 KB
testcase_15 AC 39 ms
55,484 KB
testcase_16 AC 64 ms
70,288 KB
testcase_17 AC 158 ms
78,200 KB
testcase_18 AC 323 ms
89,156 KB
testcase_19 AC 550 ms
95,828 KB
testcase_20 AC 646 ms
99,784 KB
testcase_21 AC 1,755 ms
129,192 KB
testcase_22 AC 49 ms
61,540 KB
testcase_23 AC 68 ms
70,304 KB
testcase_24 AC 62 ms
68,228 KB
testcase_25 AC 83 ms
76,276 KB
testcase_26 AC 48 ms
62,000 KB
testcase_27 AC 88 ms
76,524 KB
testcase_28 AC 89 ms
76,512 KB
testcase_29 AC 105 ms
76,952 KB
testcase_30 AC 81 ms
76,488 KB
testcase_31 AC 55 ms
63,592 KB
testcase_32 AC 402 ms
95,336 KB
testcase_33 WA -
testcase_34 AC 299 ms
89,232 KB
testcase_35 AC 539 ms
100,868 KB
testcase_36 WA -
testcase_37 AC 193 ms
81,436 KB
testcase_38 AC 1,506 ms
167,396 KB
testcase_39 AC 963 ms
136,476 KB
testcase_40 AC 1,527 ms
173,824 KB
testcase_41 AC 1,122 ms
144,972 KB
testcase_42 AC 135 ms
77,808 KB
testcase_43 AC 1,063 ms
148,816 KB
testcase_44 AC 59 ms
66,120 KB
testcase_45 AC 155 ms
78,988 KB
testcase_46 AC 455 ms
99,196 KB
testcase_47 AC 148 ms
77,892 KB
testcase_48 AC 198 ms
80,552 KB
testcase_49 AC 101 ms
76,676 KB
testcase_50 AC 98 ms
76,584 KB
testcase_51 AC 101 ms
76,600 KB
testcase_52 AC 98 ms
76,544 KB
testcase_53 AC 247 ms
80,556 KB
testcase_54 AC 207 ms
81,500 KB
testcase_55 AC 242 ms
81,656 KB
testcase_56 AC 291 ms
82,952 KB
testcase_57 WA -
testcase_58 AC 2,491 ms
148,188 KB
testcase_59 AC 2,447 ms
147,876 KB
testcase_60 AC 2,125 ms
141,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
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 = deque()
        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
            q.append((sum(abc[to]), to))
        if not q:
            return False
        else:
            c = max(c, abc[0][1])
        
        while q:
            nowsum, now = q.popleft()
            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
                    q.append((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