結果
| 問題 | No.3558 Dominoes, Black and White |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-05-29 20:54:29 |
| 言語 | Rust (1.94.0 + proconio + num + itertools) |
| 結果 |
AC
|
| 実行時間 | 30 ms / 2,000 ms |
| コード長 | 1,398 bytes |
| 記録 | |
| コンパイル時間 | 14,149 ms |
| コンパイル使用メモリ | 203,876 KB |
| 実行使用メモリ | 41,472 KB |
| 最終ジャッジ日時 | 2026-05-29 20:54:49 |
| 合計ジャッジ時間 | 8,183 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge4_0 |
| 純コード判定待ち |
(要ログイン)
| サブタスク | 配点 | 結果 |
|---|---|---|
| 部分点 | 10 % | AC * 30 |
| 満点 | 90 % | AC * 89 |
| 合計 | 100 点 |
ソースコード
#![allow(non_snake_case, unused_imports, unused_macros)]
use itertools::{Itertools, iproduct, izip};
use proconio::{fastout, input, marker::Usize1, marker::Chars};
macro_rules! debug {
($($a:expr),* $(,)*) => {
#[cfg(debug_assertions)]
eprintln!(concat!($("| ", stringify!($a), "={:?} "),*, "|"), $(&$a),*);
};
}
macro_rules! ndvec {
($v:expr; $n:expr) => {
vec![$v; $n]
};
($v:expr; $n:expr, $($ns:expr),+) => {
vec![ndvec![$v; $($ns),+]; $n]
};
}
macro_rules! yes_no {
($e:expr) => {
if $e {
println!("Yes");
} else {
println!("No");
}
};
}
#[fastout]
fn main() {
input! {
n: usize,
s: [Chars; n]
}
let whites = iproduct!(0..n, 0..n).filter(|&(i, j)| s[i][j] == '#').sorted_unstable().collect_vec();
let blacks = iproduct!(0..n, n..2 * n).filter(|&(i, j)| s[i][j] == '.').sorted_unstable().collect_vec();
println!("{}",
izip!(whites, blacks).map(|(wi, bi)| wi.0.abs_diff(bi.0) + wi.1.abs_diff(bi.1)).sum::<usize>()
);
}
#[allow(unused)]
fn partition_point<I: num::Integer + Copy>(mut l: I, mut r: I, mut f: impl FnMut(I) -> bool) {
let one = I::one();
let two = one + one;
while l < r {
let p = (r - l) / two + l;
if f(p) {
l = p + one;
} else {
r = p;
}
}
}