結果

問題 No.3679 なんかでっかい虫リターンズ
コンテスト
ユーザー norioc
提出日時 2026-09-22 17:25:55
言語 Rust
(1.97.1 + proconio + num + itertools + ACL)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 0 ms / 2,000 ms
+ 738µs
コード長 1,097 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,302 ms
コンパイル使用メモリ 194,592 KB
実行使用メモリ 9,864 KB
最終ジャッジ日時 2026-09-22 17:26:01
合計ジャッジ時間 3,212 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge5_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `H`
  --> src/main.rs:28:9
   |
28 |         H: usize,
   |         ^ help: if this is intentional, prefix it with an underscore: `_H`
   |
   = note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default

warning: unused variable: `W`
  --> src/main.rs:29:9
   |
29 |         W: usize,
   |         ^ help: if this is intentional, prefix it with an underscore: `_W`

ソースコード

diff #
raw source code

#![allow(non_snake_case, unused_imports)]

use std::cmp::{min, max};
use std::collections::{BinaryHeap, Bound, HashMap, HashSet, VecDeque};
use std::hash::Hash;
use std::ops::RangeBounds;
use ac_library::{Additive, Min, Segtree};
use proconio::{input, marker::Usize1, marker::Chars};
use itertools::Itertools;

#[allow(unused_macros)]
macro_rules! d {
    ( $( $x:expr ),* $(,)? ) => {
        eprintln!(
            concat!( $( stringify!($x), "={:?} " ),* ),
            $( $x ),*
        );
    };
}

#[allow(dead_code)]
fn yn(b: bool) -> &'static str {
    if b { "Yes" } else { "No" }
}

fn main() {
    input! {
        H: usize,
        W: usize,
        A: Usize1, B: Usize1,
        R1: Usize1, C1: Usize1,
        R2: Usize1, C2: Usize1,
        P: Usize1, Q: Usize1,
    }

    let mut ans = usize::MAX;
    for r in R1..=R2 {
        for c in C1..=C2 {
            let a = A.abs_diff(r) + B.abs_diff(c);
            let b = P.abs_diff(r) + Q.abs_diff(c);
            let c = P.abs_diff(A) + Q.abs_diff(B);

            ans = ans.min(a+b+c);
        }
    }

    println!("{}", ans);
}
0