結果

問題 No.1225 I hate I hate Matrix Construction
ユーザー StrorkisStrorkis
提出日時 2020-09-11 22:29:53
言語 Rust
(1.72.1)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 1,834 bytes
コンパイル時間 2,472 ms
コンパイル使用メモリ 141,032 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-27 15:19:50
合計ジャッジ時間 3,064 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 23 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 4 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 5 ms
4,380 KB
testcase_10 AC 7 ms
4,380 KB
testcase_11 AC 25 ms
4,380 KB
testcase_12 AC 8 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 3 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 7 ms
4,376 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let n: usize = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().parse().unwrap()
    };

    let s: Vec<u8> = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let iter = buf.split_whitespace();
        iter.map(|x| x.parse().unwrap()).collect()
    };

    let t: Vec<u8> = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let iter = buf.split_whitespace();
        iter.map(|x| x.parse().unwrap()).collect()
    };

    let mut a = vec![vec![3; n]; n];
    for i in 0..n {
        if s[i] == 1 { continue; }
        for j in 0..n {
            a[i][j] = if s[i] == 0 { 0 } else { 1 };
        }
    }
    for j in 0..n {
        if t[j] == 1 { continue; }
        for i in 0..n {
            a[i][j] = if t[j] == 0 { 0 } else { 1 };
        }
    }

    for i in 0..n {
        if s[i] != 1 || (0..n).any(|j| a[i][j] == 1) { continue; }
        for j in 0..n {
            if t[j] != 1 { continue; }
            if (0..n).any(|k| a[k][j] == 1) { continue; }
            a[i][j] = 1;
            break;
        }
    }

    for i in 0..n {
        if s[i] != 1 || (0..n).any(|j| a[i][j] == 1) { continue; }
        for j in 0..n {
            if a[i][j] == 3 {
                a[i][j] = 1;
                break;
            }
        }
    }
    for j in 0..n {
        if t[j] != 1 || (0..n).any(|i| a[i][j] == 1) { continue; }
        for i in 0..n {
            if a[i][j] == 3 {
                a[i][j] = 1;
                break;
            }
        }
    }

    let mut ans = 0;
    for i in 0..n {
        for j in 0..n {
            if a[i][j] == 1 {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}
0