結果

問題 No.3679 なんかでっかい虫リターンズ
コンテスト
ユーザー forest3
提出日時 2026-10-28 16:21:48
言語 C++14
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 2,000 ms
+ 795µs
コード長 550 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,119 ms
コンパイル使用メモリ 179,696 KB
実行使用メモリ 9,904 KB
最終ジャッジ日時 2026-10-28 16:21:56
合計ジャッジ時間 3,070 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for (ll i = a; i < b; i++)
using ll = long long;

int main(){
    int h, w, a, b, r1, c1, r2, c2, p, q;
    cin >> h >> w >> a >> b >> r1 >> c1 >> r2 >> c2 >> p >> q;
    ll inf = 1e9;
    ll ans = inf;
    if(r1 > r2) swap(r1, r2);
    if(c1 > c2) swap(c1, c2);
    rep(i, r1, r2 + 1) rep(j, c1, c2 + 1) {
        ll d = abs(a - i) + abs(b - j);
        d += abs(i - p) + abs(j - q);
        d += abs(a - p) + abs(b - q);
        ans = min(ans, d);
    }
    cout << ans << endl;
}
0