結果

問題 No.3596 Queen Score Attack 1
コンテスト
ユーザー urectanc
提出日時 2026-07-24 21:14:13
言語 Rust
(1.94.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
WA  
実行時間 -
コード長 1,248 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,032 ms
コンパイル使用メモリ 191,608 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-07-24 21:14:17
合計ジャッジ時間 3,107 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 11 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

use proconio::{fastout, input};

#[fastout]
fn main() {
    input! { t: usize }

    for _ in 0..t {
        let ans = solve();
        println!("{}", if ans { "finite" } else { "infinite" });
    }
}

fn solve() -> bool {
    input! {
        h: usize, w: usize,
        a: [[i32; w]; h],
    }

    for i in 0..h {
        for j in 0..w {
            for ni in 0..i {
                if a[ni][j] + a[i][j] > 0 {
                    return false;
                }
            }

            for nj in 0..j {
                if a[i][nj] + a[i][j] > 0 {
                    return false;
                }
            }

            for d in 0.. {
                let ni = i + d;
                let nj = j.wrapping_sub(d);
                if ni >= h || nj >= w {
                    break;
                }
                if a[ni][nj] + a[i][j] > 0 {
                    return false;
                }
            }

            for d in 0.. {
                let ni = i.wrapping_sub(d);
                let nj = j + d;
                if ni >= h || nj >= w {
                    break;
                }
                if a[ni][nj] + a[i][j] > 0 {
                    return false;
                }
            }
        }
    }

    true
}
0