結果

問題 No.3679 なんかでっかい虫リターンズ
コンテスト
ユーザー A
提出日時 2026-09-05 22:02:23
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 2,000 ms
+ 425µs
コード長 1,512 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,353 ms
コンパイル使用メモリ 350,320 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2026-09-05 22:02:31
合計ジャッジ時間 4,188 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
// #include<atcoder/all>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i,s, n) for (int i = (s); i < (n); i++)
#define ALL(x) x.begin(),x.end()
#define rALL(x) x.rbegin(),x.rend()
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
// using mint = atcoder::modint998244353;
// using Mint = atcoder::modint1000000007;
const ll INF = 1LL << 60;
const ll inf = 1E9 + 7;
const ll MOD = 998244353;
const ll mod = 1E9 + 7;
const ll int_max = 1LL << 32;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b;return true; }return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b;return true; }return false; }
template <class T>inline ll pair2idx(T x, T y, T n) { return (ll)x * n + y; }
template <class T>inline pair<int, int> idx2pair(T idx, T n) { return { idx / n, idx % n }; }

long long _pow(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret *= x;
        x *= x;
        n >>= 1;
    }
    return ret;
}

int dist(int x1,int y1,int x2,int y2){
    return abs(x1-x2)+abs(y1-y2);
}

int main(){
    int h,w;cin>>h>>w;
    int a,b;cin>>a>>b;
    int r1,c1,r2,c2;cin>>r1>>c1>>r2>>c2;
    int p,q;cin>>p>>q;
    int ans=inf;
    for(int y=r1;y<=r2;y++){
        for(int x=c1;x<=c2;x++){
            chmin(ans,dist(a,b,y,x)+dist(y,x,p,q)+dist(p,q,a,b));
        }
    }
    cout << ans<<endl;
}
0