結果

問題 No.1345 Beautiful BINGO
ユーザー BrightLightBrightLight
提出日時 2021-01-16 14:43:41
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,950 bytes
コンパイル時間 12,861 ms
コンパイル使用メモリ 378,240 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-05 17:17:46
合計ジャッジ時間 14,839 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 0 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 1 ms
5,376 KB
testcase_30 AC 1 ms
5,376 KB
testcase_31 AC 1 ms
5,376 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 1 ms
5,376 KB
testcase_35 WA -
testcase_36 AC 1 ms
5,376 KB
testcase_37 AC 1 ms
5,376 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 1 ms
5,376 KB
testcase_42 AC 1 ms
5,376 KB
testcase_43 WA -
testcase_44 AC 1 ms
5,376 KB
testcase_45 AC 1 ms
5,376 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 AC 1 ms
5,376 KB
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 AC 1 ms
5,376 KB
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 AC 1 ms
5,376 KB
testcase_61 WA -
testcase_62 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}


fn main() {
    let nm: Vec<usize> = read_vec();
    let n = nm[0];
    let m = nm[1];
    let mut a: Vec<Vec<usize>> = read_vec2(n);

    let mut ans = 0;
    for _i in 0..m {
        let mut smallest = 9999999;
        let mut pos: (usize, usize, usize) = (999, 999, 999);
        for j in 0..n {
            let mut x = 0;
            let mut y = 0;    
            for k in 0..n {
                x += a[j][k];
                y += a[k][j];
            }
            if smallest > x && x != 0 {
                smallest = x;
                pos = (j, 999, 999);
            }
            if smallest > y && y != 0 {
                smallest = y;
                pos = (999, j, 999);
            }
        }
        let mut z1 = 0;
        let mut z2 = 0;
        for k in 0..n {
            z1 += a[k][k];
            z2 += a[k][n - k - 1];
        }
        if smallest > z1 && z1 != 0 {
            smallest = z1;
            pos = (999, 999, 1);
        }
        if smallest > z2 && z2 != 0 {
            smallest = z2;
            pos = (999, 999, 2);
        }

        ans += smallest;
        if pos.0 != 999 {
            for k in 0..n {
                a[pos.0][k] = 0;
            }
        } else if pos.1 != 999 {
            for k in 0..n {
                a[k][pos.1] = 0;
            }
        } else if pos.2 == 1 {
            for k in 0..n {
                a[k][k] = 0;
            }
        } else {
            for k in 0..n {
                a[k][n - k - 1] = 0;
            }
        }
    }
    println!("{}", ans);
}
0