結果

問題 No.3596 Queen Score Attack 1
コンテスト
ユーザー gomaazarasi
提出日時 2026-07-01 15:47:36
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 154 ms / 2,000 ms
+ 209µs
コード長 1,260 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 239 ms
コンパイル使用メモリ 96,108 KB
実行使用メモリ 85,956 KB
最終ジャッジ日時 2026-07-24 20:34:09
合計ジャッジ時間 4,515 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

t = int(input())

for _ in range(t):
    h,w = list(map(int,input().split()))
    a = [ list(map(int,input().split())) for i in range(h)]
    ans = "finite"
    d0 = {}
    d1 = {}
    d2 = {}
    d3 = {}
    
    for i in range(h):
        for u in range(w):
            if i not in d0:
                d0[i] = []
            if u not in d1:
                d1[u] = []
            if i+u not in d2:
                d2[i+u] = []
            if i-u not in d3:
                d3[i-u] = []
            d0[i].append(a[i][u])
            d1[u].append(a[i][u])
            d2[i+u].append(a[i][u])
            d3[i-u].append(a[i][u])
    
    for i in d0:
        if len(d0[i]) <= 1:
            continue
        d0[i].sort()
        if d0[i][-1]+d0[i][-2] > 0:
            ans = "infinite"
    for i in d1:
        if len(d1[i]) <= 1:
            continue
        d1[i].sort()
        if d1[i][-1]+d1[i][-2] > 0:
            ans = "infinite"
    for i in d2:
        if len(d2[i]) <= 1:
            continue
        d2[i].sort()
        if d2[i][-1]+d2[i][-2] > 0:
            ans = "infinite"
    for i in d3:
        if len(d3[i]) <= 1:
            continue
        d3[i].sort()
        if d3[i][-1]+d3[i][-2] > 0:
            ans = "infinite"
    
    print(ans)
0