Submission #60508768
Source Code Expand
#[allow(unused_imports)]
use itertools::iproduct;
use proconio::{input, marker::Chars};
fn main() {
input!{
h: usize,
w: usize,
d: usize,
s: [Chars; h],
}
let mut ans = 0;
for (ai, aj) in iproduct!(0..h, 0..w) {
if s[ai][aj] == '#' {
continue;
}
for (bi, bj) in iproduct!(0..h, 0..w) {
if ai == bi && aj == bj {
continue;
}
if s[bi][bj] == '#' {
continue;
}
let mut cnt = 0;
for (i, j) in iproduct!(0..h, 0..w) {
if s[i][j] == '#' {
continue;
}
let dist = (ai.abs_diff(i) + aj.abs_diff(j)).min(bi.abs_diff(i) + bj.abs_diff(j));
if dist <= d {
cnt += 1;
}
}
ans.chmax(cnt);
}
}
println!("{ans}");
}
pub trait ChLibs<T: std::cmp::Ord> {
fn chmin(&mut self, elm: T) -> bool;
fn chmax(&mut self, elm: T) -> bool;
}
impl<T: std::cmp::Ord> ChLibs<T> for T {
fn chmin(&mut self, elm: T) -> bool {
if *self > elm {
*self = elm;
true
} else {
false
}
}
fn chmax(&mut self, elm: T) -> bool {
if *self < elm {
*self = elm;
true
} else {
false
}
}
}
pub trait Debuggable {
fn debug_string(&self) -> String;
}
impl<T: std::fmt::Debug + std::fmt::Display> Debuggable for Vec<T> {
fn debug_string(&self) -> String {
use itertools::Itertools;
use std::iter::repeat;
if let Some(max_size) = self.iter()
.map(|x| format!("{:?}", x).len())
.max() {
let mut idx = String::from("idx |");
let mut val = String::from("val |");
for (i, xi) in self.iter().enumerate() {
idx.push_str(
&format!(" {:>w$} |", i, w=max_size)
);
val.push_str(
&format!(" {:>w$} |", xi, w=max_size)
);
}
format!("{}\n{}\n{}\n", idx, repeat('-').take(idx.len()).join(""), val)
} else {
format!("idx | \nval |\n")
}
}
}
impl<T: std::fmt::Debug + std::fmt::Display> Debuggable for std::collections::BTreeSet<T> {
fn debug_string(&self) -> String {
use itertools::Itertools;
format!("{{ {} }}", self.iter().join(", "))
}
}
impl<T, U> Debuggable for std::collections::BTreeMap<T, U>
where T: std::fmt::Debug + std::fmt::Display, U: std::fmt::Debug + std::fmt::Display
{
fn debug_string(&self) -> String {
use itertools::Itertools;
format!(
"{{\n{}\n }}", self.iter()
.map(|(k, v)| format!("{k} -> {v}, "))
.join("\n")
)
}
}
// lg! マクロの定義
#[macro_export]
macro_rules! lg {
($val:expr) => {
#[cfg(feature = "local")]
{
{
use Debuggable;
let val = &$val;
eprintln!(
"[{}:{}] {} = \n{}",
file!(),
line!(),
stringify!($val),
val.debug_string()
);
val
}
}
}
}
Submission Info
Submission Time |
|
Task |
B - Humidifier 2 |
User |
ardRiriy |
Language |
Rust (rustc 1.70.0) |
Score |
250 |
Code Size |
3472 Byte |
Status |
AC |
Exec Time |
5 ms |
Memory |
2080 KiB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
250 / 250 |
Status |
|
|
Set Name |
Test Cases |
Sample |
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
All |
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt |
Case Name |
Status |
Exec Time |
Memory |
00_sample_00.txt |
AC |
1 ms |
2016 KiB |
00_sample_01.txt |
AC |
1 ms |
2080 KiB |
00_sample_02.txt |
AC |
1 ms |
1928 KiB |
01_test_00.txt |
AC |
1 ms |
1944 KiB |
01_test_01.txt |
AC |
1 ms |
2072 KiB |
01_test_02.txt |
AC |
1 ms |
1972 KiB |
01_test_03.txt |
AC |
1 ms |
2060 KiB |
01_test_04.txt |
AC |
1 ms |
2000 KiB |
01_test_05.txt |
AC |
1 ms |
1984 KiB |
01_test_06.txt |
AC |
1 ms |
1928 KiB |
01_test_07.txt |
AC |
1 ms |
1924 KiB |
01_test_08.txt |
AC |
1 ms |
1992 KiB |
01_test_09.txt |
AC |
1 ms |
1856 KiB |
01_test_10.txt |
AC |
1 ms |
1992 KiB |
01_test_11.txt |
AC |
1 ms |
1972 KiB |
01_test_12.txt |
AC |
1 ms |
1736 KiB |
01_test_13.txt |
AC |
1 ms |
1864 KiB |
01_test_14.txt |
AC |
1 ms |
1912 KiB |
01_test_15.txt |
AC |
1 ms |
1924 KiB |
01_test_16.txt |
AC |
1 ms |
1888 KiB |
01_test_17.txt |
AC |
1 ms |
1928 KiB |
01_test_18.txt |
AC |
1 ms |
2064 KiB |
01_test_19.txt |
AC |
5 ms |
1992 KiB |
01_test_20.txt |
AC |
5 ms |
1968 KiB |
01_test_21.txt |
AC |
4 ms |
1972 KiB |
01_test_22.txt |
AC |
1 ms |
1868 KiB |