結果

問題 No.5016 Worst Mayor
ユーザー shim0shim0
提出日時 2023-04-29 17:00:33
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 2,462 bytes
コンパイル時間 1,250 ms
コンパイル使用メモリ 87,060 KB
実行使用メモリ 26,112 KB
スコア 0
最終ジャッジ日時 2023-04-29 17:06:47
合計ジャッジ時間 7,497 ms
ジャッジサーバーID
(参考情報)
judge16 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    _n, _t = map(int, input().split())
    dp = [[0 for j in range(14 * 14)] for i in range(14 * 14)]
    for start_i in range(0, 14):
        for start_j in range(0, 14):
            for goal_i in range(0, 14):
                for goal_j in range(0, 14):
                    value = abs(start_i - start_j) + abs(goal_i - goal_j)
                    dp[start_i * 14 + start_j][goal_i * 14 + goal_j] = value * 1000
                    dp[goal_i * 14 + goal_j][start_i * 14 + start_j] = value * 1000
    sum_s = 0
    paths = {}
    for _ in range(3000):
        a, b, c, d = map(int, input().split())
        a -= 1
        b -= 1
        c -= 1
        d -= 1
        paths[(a, b, c, d)] = dp[a * 14 + b][c * 14 + d]
        paths[(a, b, c, d)] = dp[c * 14 + d][a * 14 + b]
    highway_count = 0
    collaborator_count = 0
    money = 10**6

    edges = []
    for i in range(14):
        for j in range(14):
            for (di, dj) in [(1, 0), (0, 1), (-1, 0), (0, -1)]:
                idi = i + di
                jdj = j + dj
                if 0 <= idi < 14 and 0 <= jdj < 14:
                    if (i, j, idi, jdj) not in edges:
                        edges.append((i, j, idi, jdj))

    best_edges = []
    for edge in edges:
        edge_value = 0
        for start_i in range(0, 14):
            for start_j in range(0, 14):
                for goal_i in range(0, 14):
                    for goal_j in range(0, 14):
                        (x, y, z, w) = edge
                        new_length = min(
                            paths[start_i * 14 + start_j][x * 14 + y] + paths[z * 14 + w][goal_i * 14 + goal_j],
                            paths[start_i * 14 + start_j][z * 14 + w] + paths[x * 14 + y][goal_i * 14 + goal_j],
                        )
                        if dp[start_i * 14 + start_j][goal_i * 14 + goal_j] > new_length:
                            edge_value += 1
        best_edges.append((edge_value, edge))
    best_edges.sort(reverse=True)

    for t in range(400):
        u, v = map(int, input().split())
        money = u
        collaborator_count = v

        idx = 0

        if collaborator_count < 25:
            print(2, flush=True)
        elif money < 10**7 // 5 or highway_count >= 20:
            print(3, flush=True)
        else:
            x, y, z, w = best_edges[idx]
            idx += 1
            print(1, x + 1, y + 1, z + 1, w + 1, flush=True)


if "__main__" == __name__:
    main()
0