結果
| 問題 | No.3596 Queen Score Attack 1 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-07-25 14:20:51 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 419 ms / 2,000 ms |
| + 668µs | |
| コード長 | 1,027 bytes |
| 記録 | |
| コンパイル時間 | 537 ms |
| コンパイル使用メモリ | 95,600 KB |
| 実行使用メモリ | 85,120 KB |
| 最終ジャッジ日時 | 2026-07-25 14:21:04 |
| 合計ジャッジ時間 | 6,430 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 31 |
ソースコード
# https://yukicoder.me/problems/no/3596
def same_line(h0, w0, h1, w1):
if h0 == h1 or w0 == w1:
return True
elif h0 - w0 == h1 - w1:
return True
elif h0 + w0 == h1 + w1:
return True
return False
def solve(H, W, A):
for index0 in range(H * W):
for index1 in range(index0 + 1, H * W):
h0 = index0 // W
w0 = index0 % W
h1 = index1 // W
w1 = index1 % W
if same_line(h0, w0, h1, w1):
a0 = A[h0][w0]
a1 = A[h1][w1]
v = a0 + a1
if v > 0:
return "infinite"
return "finite"
def main():
T = int(input())
answers = []
for _ in range(T):
H, W = map(int, input().split())
A = []
for _ in range(H):
A.append(list(map(int, input().split())))
ans = solve(H, W, A)
answers.append(ans)
for ans in answers:
print(ans)
if __name__ == "__main__":
main()