結果
問題 | No.1668 Grayscale |
ユーザー | akakimidori |
提出日時 | 2021-09-03 22:07:37 |
言語 | Rust (1.77.0 + proconio) |
結果 |
AC
|
実行時間 | 1,302 ms / 4,000 ms |
コード長 | 2,417 bytes |
コンパイル時間 | 13,527 ms |
コンパイル使用メモリ | 378,592 KB |
実行使用メモリ | 165,632 KB |
最終ジャッジ日時 | 2024-05-09 04:13:56 |
合計ジャッジ時間 | 17,727 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
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 | AC | 1 ms
5,376 KB |
testcase_06 | AC | 362 ms
163,200 KB |
testcase_07 | AC | 359 ms
165,632 KB |
testcase_08 | AC | 47 ms
31,232 KB |
testcase_09 | AC | 1,302 ms
145,664 KB |
testcase_10 | AC | 244 ms
43,264 KB |
testcase_11 | AC | 1 ms
5,376 KB |
testcase_12 | AC | 1 ms
5,376 KB |
testcase_13 | AC | 34 ms
10,496 KB |
testcase_14 | AC | 147 ms
27,136 KB |
testcase_15 | AC | 50 ms
11,520 KB |
testcase_16 | AC | 29 ms
7,808 KB |
testcase_17 | AC | 19 ms
7,168 KB |
testcase_18 | AC | 1 ms
5,376 KB |
testcase_19 | AC | 1 ms
5,376 KB |
testcase_20 | AC | 1 ms
5,376 KB |
testcase_21 | AC | 2 ms
5,376 KB |
testcase_22 | AC | 1 ms
5,376 KB |
testcase_23 | AC | 1 ms
5,376 KB |
コンパイルメッセージ
warning: unused import: `std::io::Write` --> src/main.rs:51:5 | 51 | use std::io::Write; | ^^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default warning: unused variable: `n` --> src/main.rs:62:9 | 62 | n: usize, | ^ | help: `n` is captured in macro and introduced a unused variable --> src/main.rs:24:13 | 24 | let $var = read_value!($iter, $t); | ^^^^ ... 59 | / input! { 60 | | h: usize, 61 | | w: usize, 62 | | n: usize, 63 | | c: [[usize; w]; h], 64 | | } | |_____- in this macro invocation = note: `#[warn(unused_variables)]` on by default = note: this warning originates in the macro `input_inner` which comes from the expansion of the macro `input` (in Nightly builds, run with -Z macro-backtrace for more info) warning: type alias `Set` is never used --> src/main.rs:55:6 | 55 | type Set<T> = BTreeSet<T>; | ^^^ | = note: `#[warn(dead_code)]` on by default warning: type alias `Deque` is never used --> src/main.rs:56:6 | 56 | type Deque<T> = VecDeque<T>; | ^^^^^
ソースコード
// ---------- begin input macro ---------- // reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); input_inner!{iter, $($r)*} }; ($($r:tt)*) => { let s = { use std::io::Read; let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); s }; let mut iter = s.split_whitespace(); input_inner!{iter, $($r)*} }; } macro_rules! input_inner { ($iter:expr) => {}; ($iter:expr, ) => {}; ($iter:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($iter, $t); input_inner!{$iter $($r)*} }; } macro_rules! read_value { ($iter:expr, ( $($t:tt),* )) => { ( $(read_value!($iter, $t)),* ) }; ($iter:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>() }; ($iter:expr, chars) => { read_value!($iter, String).chars().collect::<Vec<char>>() }; ($iter:expr, bytes) => { read_value!($iter, String).bytes().collect::<Vec<u8>>() }; ($iter:expr, usize1) => { read_value!($iter, usize) - 1 }; ($iter:expr, $t:ty) => { $iter.next().unwrap().parse::<$t>().expect("Parse error") }; } // ---------- end input macro ---------- use std::io::Write; use std::collections::*; type Map<K, V> = BTreeMap<K, V>; type Set<T> = BTreeSet<T>; type Deque<T> = VecDeque<T>; fn run() { input! { h: usize, w: usize, n: usize, c: [[usize; w]; h], } let mut map = Map::new(); for (i, c) in c.iter().enumerate() { for (j, c) in c.iter().enumerate() { map.entry(*c).or_insert(vec![]).push((i, j)); } } let mut max = 1; let mut board = vec![vec![0; w]; h]; for (_, pos) in map { let mut add = 0; for &(x, y) in pos.iter() { for &(dx, dy) in [(1, 0), (0, 1), (!0, 0), (0, !0)].iter() { let x = x + dx; let y = y + dy; if x < h && y < w && board[x][y] == max { add = 1; } } } max += add; for (x, y) in pos { board[x][y] = max; } } println!("{}", max); } fn main() { run(); }