結果

問題 No.5019 Hakai Project
ユーザー とろちゃとろちゃ
提出日時 2023-11-17 19:48:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 142 ms / 3,000 ms
コード長 3,246 bytes
コンパイル時間 213 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 80,332 KB
スコア 87,247,050
最終ジャッジ日時 2023-11-17 19:48:15
合計ジャッジ時間 12,390 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
78,924 KB
testcase_01 AC 114 ms
78,924 KB
testcase_02 AC 104 ms
78,540 KB
testcase_03 AC 110 ms
79,052 KB
testcase_04 AC 109 ms
78,924 KB
testcase_05 AC 100 ms
78,544 KB
testcase_06 AC 103 ms
79,052 KB
testcase_07 AC 104 ms
78,924 KB
testcase_08 AC 96 ms
78,412 KB
testcase_09 AC 109 ms
78,924 KB
testcase_10 AC 96 ms
78,284 KB
testcase_11 AC 104 ms
78,796 KB
testcase_12 AC 109 ms
78,924 KB
testcase_13 AC 112 ms
79,052 KB
testcase_14 AC 115 ms
80,076 KB
testcase_15 AC 118 ms
79,820 KB
testcase_16 AC 108 ms
78,924 KB
testcase_17 AC 102 ms
78,668 KB
testcase_18 AC 108 ms
79,180 KB
testcase_19 AC 109 ms
78,924 KB
testcase_20 AC 106 ms
78,924 KB
testcase_21 AC 109 ms
78,924 KB
testcase_22 AC 116 ms
80,076 KB
testcase_23 AC 135 ms
78,924 KB
testcase_24 AC 112 ms
80,332 KB
testcase_25 AC 109 ms
78,796 KB
testcase_26 AC 102 ms
79,052 KB
testcase_27 AC 114 ms
80,204 KB
testcase_28 AC 107 ms
78,796 KB
testcase_29 AC 109 ms
78,668 KB
testcase_30 AC 109 ms
79,308 KB
testcase_31 AC 142 ms
79,180 KB
testcase_32 AC 111 ms
79,052 KB
testcase_33 AC 111 ms
78,796 KB
testcase_34 AC 108 ms
79,180 KB
testcase_35 AC 120 ms
79,052 KB
testcase_36 AC 110 ms
79,180 KB
testcase_37 AC 114 ms
79,180 KB
testcase_38 AC 112 ms
79,436 KB
testcase_39 AC 103 ms
78,540 KB
testcase_40 AC 109 ms
79,180 KB
testcase_41 AC 108 ms
78,924 KB
testcase_42 AC 109 ms
79,052 KB
testcase_43 AC 102 ms
78,668 KB
testcase_44 AC 115 ms
80,076 KB
testcase_45 AC 103 ms
78,924 KB
testcase_46 AC 116 ms
78,668 KB
testcase_47 AC 107 ms
78,924 KB
testcase_48 AC 103 ms
78,796 KB
testcase_49 AC 109 ms
78,796 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# import pypyjit;pypyjit.set_param("max_unroll_recursion=-1")
import os
import sys

# from bisect import *
from collections import *

# from datetime import *
# from decimal import *  # PyPyだと遅い
# from heapq import *
# from itertools import *
# from math import gcd, lcm
# from random import *
# from string import *

# import numpy as np
# from atcoder.dsu import *
# from atcoder.segtree import *
# from more_itertools import *
# from sortedcontainers import *

# sys.setrecursionlimit(10**7)  # PyPyは呪文を付ける
# sys.set_int_max_str_digits(0)
INF = 1 << 61
MOD = 998244353
# MOD = 10**9 + 7
IS_ATCODER = os.getenv("ATCODER", 0)

File = sys.stdin


def input():
    return File.readline()[:-1]


# ///////////////////////////////////////////////////////////////////////////
def move(p1):
    global ans, haruku
    haruku = list(haruku)
    y2, x2 = p1
    while haruku[1] != x2:
        if haruku[1] < x2:
            ans.append([1, "R"])
            haruku[1] += 1
        else:
            ans.append([1, "L"])
            haruku[1] -= 1
    while haruku[0] != y2:
        if haruku[0] < y2:
            ans.append([1, "D"])
            haruku[0] += 1
        else:
            ans.append([1, "U"])
            haruku[0] -= 1
    haruku = tuple(haruku)


def calc_dist(p1, p2):
    return abs(p1[0] - p2[0]) + abs(p1[1] - p2[1])


def buy_bomb(p1):
    nxt = (INF, INF)
    for i in shop:
        dist = calc_dist(p1, i)
        if calc_dist(p1, nxt) > dist:
            nxt = i
    move(nxt)
    # print(A[haruku[0]][haruku[1]])
    for _ in range(50):
        for b in bomb[use][2]:
            ans.append([2, b])


N, M = map(int, input().split())
A = [list(input()) for _ in range(N)]
bomb = []
for i in range(M):
    C, L = map(int, input().split())
    bomb.append([C, set([tuple(map(int, input().split())) for _ in range(L)]), [i + 1]])

for i in range(M):
    for j in range(i + 1, M):
        bomb.append(
            [bomb[i][0] + bomb[j][0], bomb[i][1] | bomb[j][1], bomb[i][2] + bomb[j][2]]
        )

shop = set()
building = set()
for i in range(N):
    for j in range(N):
        if A[i][j] == "@":
            shop.add((i, j))
        elif A[i][j] == "#":
            building.add((i, j))

# bomb.sort(key=lambda x:x[1]/x[0],reverse=True)
mn = INF
for i in range(len(bomb)):
    if bomb[i][0] > mn:
        continue
    s1 = set()
    s2 = set()
    for j, k in bomb[i][1]:
        if k >= 0:
            s1.add(j)
        if k <= 0:
            s2.add(j)
    if len(s1) == 41 and len(s2) == 41:
        use = i
        mn = bomb[i][0]
ans = deque()

haruku = (0, 0)

for t in [(20, 0, "R", 1), (40, 49, "L", -1)]:
    start = (t[0], t[1])
    buy_bomb(haruku)
    move(start)
    for k in range(50):
        for b in bomb[use][2]:
            ans.append([3, b])
        for i, j in bomb[use][1]:
            shop.discard((haruku[0] + i, haruku[1] + j))
            try:
                A[haruku[0] + i][haruku[1] + j] = "."
            except IndexError:
                pass
        if k == 49:
            break
        ans.append([1, t[2]])
        haruku = (haruku[0], haruku[1] + t[3])
        # print(haruku)

    # for i in A:
    #     print("".join(i))

print(len(ans))
for i in ans:
    print(*i)
0