結果

問題 No.2509 Beam Shateki
ユーザー mkawa2mkawa2
提出日時 2023-10-20 22:00:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,626 ms / 2,000 ms
コード長 1,877 bytes
コンパイル時間 228 ms
コンパイル使用メモリ 81,804 KB
実行使用メモリ 86,928 KB
最終ジャッジ日時 2023-10-20 22:01:40
合計ジャッジ時間 55,104 ms
ジャッジサーバーID
(参考情報)
judge10 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
60,904 KB
testcase_01 AC 41 ms
58,856 KB
testcase_02 AC 37 ms
53,628 KB
testcase_03 AC 583 ms
82,664 KB
testcase_04 AC 618 ms
83,536 KB
testcase_05 AC 594 ms
83,404 KB
testcase_06 AC 604 ms
83,860 KB
testcase_07 AC 599 ms
83,424 KB
testcase_08 AC 604 ms
83,312 KB
testcase_09 AC 579 ms
83,888 KB
testcase_10 AC 624 ms
83,536 KB
testcase_11 AC 617 ms
83,540 KB
testcase_12 AC 617 ms
83,856 KB
testcase_13 AC 1,574 ms
86,692 KB
testcase_14 AC 1,602 ms
86,660 KB
testcase_15 AC 1,608 ms
86,608 KB
testcase_16 AC 1,618 ms
86,684 KB
testcase_17 AC 1,626 ms
86,736 KB
testcase_18 AC 1,575 ms
86,764 KB
testcase_19 AC 1,587 ms
86,740 KB
testcase_20 AC 1,623 ms
86,612 KB
testcase_21 AC 1,611 ms
86,696 KB
testcase_22 AC 1,619 ms
86,696 KB
testcase_23 AC 1,592 ms
86,744 KB
testcase_24 AC 1,610 ms
86,608 KB
testcase_25 AC 1,585 ms
86,612 KB
testcase_26 AC 1,599 ms
86,732 KB
testcase_27 AC 1,567 ms
86,684 KB
testcase_28 AC 1,617 ms
86,688 KB
testcase_29 AC 1,584 ms
86,676 KB
testcase_30 AC 1,575 ms
86,616 KB
testcase_31 AC 1,612 ms
86,496 KB
testcase_32 AC 1,578 ms
86,616 KB
testcase_33 AC 329 ms
79,676 KB
testcase_34 AC 767 ms
85,052 KB
testcase_35 AC 1,068 ms
85,696 KB
testcase_36 AC 545 ms
84,360 KB
testcase_37 AC 183 ms
77,360 KB
testcase_38 AC 573 ms
84,112 KB
testcase_39 AC 545 ms
82,420 KB
testcase_40 AC 812 ms
85,384 KB
testcase_41 AC 142 ms
77,844 KB
testcase_42 AC 639 ms
84,008 KB
testcase_43 AC 1,173 ms
86,160 KB
testcase_44 AC 1,310 ms
86,296 KB
testcase_45 AC 547 ms
82,844 KB
testcase_46 AC 743 ms
82,640 KB
testcase_47 AC 1,325 ms
86,928 KB
testcase_48 AC 702 ms
83,880 KB
testcase_49 AC 886 ms
85,112 KB
testcase_50 AC 958 ms
85,860 KB
testcase_51 AC 342 ms
81,324 KB
testcase_52 AC 800 ms
85,460 KB
testcase_53 AC 45 ms
61,544 KB
testcase_54 AC 45 ms
61,544 KB
testcase_55 AC 47 ms
63,904 KB
testcase_56 AC 48 ms
63,904 KB
testcase_57 AC 49 ms
63,904 KB
testcase_58 AC 47 ms
63,904 KB
testcase_59 AC 48 ms
63,904 KB
testcase_60 AC 49 ms
63,904 KB
testcase_61 AC 49 ms
63,904 KB
testcase_62 AC 47 ms
63,904 KB
testcase_63 AC 53 ms
63,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
# sys.set_int_max_str_digits(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = -1-(-1 << 31)
# inf = -1-(-1 << 63)
# md = 10**9+7
md = 998244353

memo = {}
ijs = {}
def line(si, sj, di, dj):
    if (si, sj, di, dj) in memo: return memo[si, sj, di, dj]
    res = 0
    i, j = si, sj
    st = set()
    while 0 <= i < h and 0 <= j < w:
        st.add((i, j))
        res += aa[i][j]
        i, j = i+di, j+dj
    memo[si, sj, di, dj] = res
    ijs[si, sj, di, dj] = st
    return res

def cross(i, j, di, dj, p, q, dp, dq):
    s=ijs[i, j, di, dj]
    t=ijs[p, q, dp, dq]
    if len(s)>len(t):s,t=t,s
    for a in s:
        if a in t:return a
    return -1,-1

def start():
    for i in range(h):
        yield i, 0, 0, 1
        yield i, 0, -1, 1
        yield i, 0, 1, 1
    for j in range(w):
        yield 0, j, 1, 0
        yield 0, j, 1, 1
        yield h-1, j, -1, 1

h, w = LI()
aa = LLI(h)
ans = 0
for i, j, di, dj in start():
    for p, q, dp, dq in start():
        if (i, j, di, dj) == (p, q, dp, dq): continue
        cur = line(i, j, di, dj)+line(p, q, dp, dq)
        ci, cj = cross(i, j, di, dj, p, q, dp, dq)
        if ci != -1: cur -= aa[ci][cj]
        if cur > ans: ans = cur
        # print(ans, i, j, di, dj, p, q, dp, dq)

print(ans)
0