結果

問題 No.3596 Queen Score Attack 1
コンテスト
ユーザー nikoro256
提出日時 2026-07-24 21:21:11
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 819 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 232 ms
コンパイル使用メモリ 95,988 KB
実行使用メモリ 86,840 KB
最終ジャッジ日時 2026-07-24 21:21:17
合計ジャッジ時間 5,259 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 30 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import defaultdict
T=int(input())
for _ in range(T):
    H,W=map(int,input().split())
    A=[]
    for _ in range(H):
        A.append(list(map(int,input().split())))
    inf = 10**18
    x = defaultdict(lambda:-inf)
    y = defaultdict(lambda:-inf)
    xpy = defaultdict(lambda:-inf)
    xsy = defaultdict(lambda:-inf)
    ans = -1
    for i in range(H):
        for j in range(W):
            ans = max(ans, A[i][j] + x[i])
            x[i] = max(x[i],A[i][j])
            ans = max(ans, A[i][j] + y[i])
            y[i] = max(y[i],A[i][j])
            ans = max(ans, A[i][j] + xpy[i+j])
            xpy[i+j] = max(xpy[i+j],A[i][j])
            ans = max(ans, A[i][j] + xsy[i-j])
            xsy[i-j] = max(xsy[i-j],A[i][j])
    if ans > 0:
        print("infinite")
    else:
        print("finite")
0