結果
問題 | No.402 最も海から遠い場所 |
ユーザー | phspls |
提出日時 | 2022-12-24 02:05:53 |
言語 | Rust (1.77.0 + proconio) |
結果 |
AC
|
実行時間 | 406 ms / 3,000 ms |
コード長 | 2,054 bytes |
コンパイル時間 | 12,825 ms |
コンパイル使用メモリ | 402,592 KB |
実行使用メモリ | 90,132 KB |
最終ジャッジ日時 | 2024-11-18 05:05:14 |
合計ジャッジ時間 | 16,231 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,816 KB |
testcase_01 | AC | 1 ms
6,816 KB |
testcase_02 | AC | 1 ms
6,820 KB |
testcase_03 | AC | 1 ms
6,820 KB |
testcase_04 | AC | 1 ms
6,820 KB |
testcase_05 | AC | 1 ms
6,820 KB |
testcase_06 | AC | 1 ms
6,816 KB |
testcase_07 | AC | 1 ms
6,820 KB |
testcase_08 | AC | 1 ms
6,820 KB |
testcase_09 | AC | 1 ms
6,816 KB |
testcase_10 | AC | 1 ms
6,820 KB |
testcase_11 | AC | 1 ms
6,820 KB |
testcase_12 | AC | 1 ms
6,816 KB |
testcase_13 | AC | 3 ms
6,816 KB |
testcase_14 | AC | 1 ms
6,820 KB |
testcase_15 | AC | 10 ms
6,816 KB |
testcase_16 | AC | 16 ms
6,816 KB |
testcase_17 | AC | 160 ms
44,304 KB |
testcase_18 | AC | 406 ms
27,912 KB |
testcase_19 | AC | 90 ms
19,584 KB |
testcase_20 | AC | 334 ms
20,096 KB |
testcase_21 | AC | 179 ms
90,132 KB |
コンパイルメッセージ
warning: unused import: `arch::x86_64::_MM_GET_ROUNDING_MODE` --> src/main.rs:1:34 | 1 | use std::{collections::VecDeque, arch::x86_64::_MM_GET_ROUNDING_MODE}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default warning: use of deprecated function `std::arch::x86_64::_MM_GET_ROUNDING_MODE`: see `_mm_getcsr` documentation - use inline assembly instead --> src/main.rs:1:48 | 1 | use std::{collections::VecDeque, arch::x86_64::_MM_GET_ROUNDING_MODE}; | ^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(deprecated)]` on by default
ソースコード
use std::{collections::VecDeque, arch::x86_64::_MM_GET_ROUNDING_MODE}; const DX: [isize; 8] = [-1, -1, -1, 0, 0, 1, 1, 1]; const DY: [isize; 8] = [-1, 0, 1, -1, 1, -1, 0, 1]; const INF: u16 = 30000u16; fn main() { let mut hw = String::new(); std::io::stdin().read_line(&mut hw).ok(); let hw: Vec<usize> = hw.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let h = hw[0]; let w = hw[1]; let mut grid = Vec::with_capacity(h+2); grid.push(vec![0u16; w+2]); for _ in 0..h { let mut line = vec![INF; w+2]; line[0] = 0; line[w+1] = 0; let mut temp = String::new(); std::io::stdin().read_line(&mut temp).ok(); let temp = temp.trim().chars().collect::<Vec<_>>(); for i in 0..w { if temp[i] == '.' { line[i+1] = 0; } } grid.push(line); } grid.push(vec![0u16; w+2]); let mut deque = VecDeque::new(); for i in 1..=h { for j in 1..=w { if grid[i][j] == 0 { continue; } for dir in 0..8 { let nx = i as isize + DX[dir]; let nx = nx as usize; let ny = j as isize + DY[dir]; let ny = ny as usize; if grid[nx][ny] == 0 { grid[i][j] = 1; deque.push_back((i, j)); break; } } } } while let Some((i, j)) = deque.pop_front() { let nval = grid[i][j] + 1; for dir in 0..8 { let nx = i as isize + DX[dir]; let nx = nx as usize; let ny = j as isize + DY[dir]; let ny = ny as usize; if grid[nx][ny] > nval { grid[nx][ny] = nval; deque.push_back((nx, ny)); } } } // for v in grid.iter() { eprintln!("{:?}", v.iter().map(|j| j.to_string()).collect::<Vec<_>>().join("")); } println!("{}", grid.iter().map(|v| v.iter().max().unwrap()).max().unwrap()); }