結果
問題 | No.179 塗り分け |
ユーザー | iwot |
提出日時 | 2020-06-22 10:03:41 |
言語 | Rust (1.77.0 + proconio) |
結果 |
AC
|
実行時間 | 134 ms / 3,000 ms |
コード長 | 2,029 bytes |
コンパイル時間 | 13,751 ms |
コンパイル使用メモリ | 387,992 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-23 15:15:10 |
合計ジャッジ時間 | 16,848 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,812 KB |
testcase_01 | AC | 1 ms
6,816 KB |
testcase_02 | AC | 1 ms
6,816 KB |
testcase_03 | AC | 0 ms
6,940 KB |
testcase_04 | AC | 1 ms
6,940 KB |
testcase_05 | AC | 12 ms
6,944 KB |
testcase_06 | AC | 1 ms
6,944 KB |
testcase_07 | AC | 1 ms
6,940 KB |
testcase_08 | AC | 67 ms
6,940 KB |
testcase_09 | AC | 67 ms
6,944 KB |
testcase_10 | AC | 1 ms
6,944 KB |
testcase_11 | AC | 1 ms
6,940 KB |
testcase_12 | AC | 70 ms
6,940 KB |
testcase_13 | AC | 1 ms
6,944 KB |
testcase_14 | AC | 1 ms
6,944 KB |
testcase_15 | AC | 1 ms
6,940 KB |
testcase_16 | AC | 1 ms
6,940 KB |
testcase_17 | AC | 1 ms
6,940 KB |
testcase_18 | AC | 3 ms
6,940 KB |
testcase_19 | AC | 2 ms
6,940 KB |
testcase_20 | AC | 69 ms
6,940 KB |
testcase_21 | AC | 75 ms
6,940 KB |
testcase_22 | AC | 76 ms
6,940 KB |
testcase_23 | AC | 1 ms
6,940 KB |
testcase_24 | AC | 72 ms
6,944 KB |
testcase_25 | AC | 2 ms
6,940 KB |
testcase_26 | AC | 19 ms
6,944 KB |
testcase_27 | AC | 103 ms
6,944 KB |
testcase_28 | AC | 10 ms
6,940 KB |
testcase_29 | AC | 122 ms
6,944 KB |
testcase_30 | AC | 66 ms
6,944 KB |
testcase_31 | AC | 134 ms
6,940 KB |
testcase_32 | AC | 45 ms
6,940 KB |
testcase_33 | AC | 119 ms
6,944 KB |
testcase_34 | AC | 36 ms
6,944 KB |
testcase_35 | AC | 128 ms
6,940 KB |
testcase_36 | AC | 1 ms
6,944 KB |
testcase_37 | AC | 1 ms
6,944 KB |
testcase_38 | AC | 1 ms
6,944 KB |
testcase_39 | AC | 1 ms
6,940 KB |
testcase_40 | AC | 1 ms
6,944 KB |
testcase_41 | AC | 1 ms
6,940 KB |
testcase_42 | AC | 0 ms
6,940 KB |
testcase_43 | AC | 4 ms
6,940 KB |
testcase_44 | AC | 17 ms
6,944 KB |
testcase_45 | AC | 1 ms
6,940 KB |
コンパイルメッセージ
warning: variable `H` should have a snake case name --> src/main.rs:28:9 | 28 | read!(H:usize, W:usize); | ^ help: convert the identifier to snake case: `h` | = note: `#[warn(non_snake_case)]` on by default warning: variable `W` should have a snake case name --> src/main.rs:28:18 | 28 | read!(H:usize, W:usize); | ^ help: convert the identifier to snake case (notice the capitalization): `w`
ソースコード
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() } macro_rules! read { ($x:ident, $v:expr, $idx:expr, $type:ty) => { let $x:$type = $v[$idx].clone().parse().unwrap(); }; ( $($x:ident:$t:ty),* ) => { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); let input:Vec<String> = s.trim() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect(); let mut idx:i64 = -1; $( idx += 1; read!($x, input, idx as usize, $t); )* }; } fn main() { read!(H:usize, W:usize); let s:Vec<Vec<usize>> = (0..H).map(|_| { let line:String = read(); line.chars().map(|c| if c == '#' {1} else {0}).collect() }).collect(); let is_all_zero = |list: &Vec<Vec<usize>>| { for i in 0..list.len() { for j in 0..list[i].len() { if list[i][j] == 1 { return false; } } } true }; if is_all_zero(&s) { println!("NO"); } else { let mut dh_range: Vec<i64> = vec![]; let mut dw_range: Vec<i64> = vec![]; for i in 0..H { dh_range.push(-1*(i as i64)); dh_range.push(i as i64); } for i in 0..W { dw_range.push(-1*(i as i64)); dw_range.push(i as i64); } let mut result = "NO"; 'outer: for dh in &dh_range { for dw in &dw_range { if *dw == 0 && *dh == 0 { continue; } let mut check = s.clone(); for h in 0..H { for w in 0..W { let nh = h as i64 + dh; let nw = w as i64 + dw; if nh >= 0 && nh < H as i64 && nw >= 0 && nw < W as i64 && check[h][w] == 1 && check[nh as usize][nw as usize] == 1 { check[h][w] = 0; check[nh as usize][nw as usize] = 0; } } } if is_all_zero(&check) { result = "YES"; break 'outer; } } } println!("{}", result); } }