結果

問題 No.3596 Queen Score Attack 1
コンテスト
ユーザー nikoro256
提出日時 2026-07-24 21:28:12
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 187 ms / 2,000 ms
+ 999µs
コード長 819 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 233 ms
コンパイル使用メモリ 96,104 KB
実行使用メモリ 87,096 KB
最終ジャッジ日時 2026-07-24 21:28:18
合計ジャッジ時間 5,350 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

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[j])
            y[j] = max(y[j],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