結果

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

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep1(i,n) for(int i=1; i<=(n); i++)
#define sz(x) int(x.size())
#define all(x) (x).begin(),(x).end()
#define lINF ll(1e18)//LONG_LONG_MAX  //ll -9223372036854775808 〜 9223372036854775807
#define iINF int(1e9+100)//INT_MAX //int  -2147483648 〜 2147483647
#define yes cout << "Yes" << '\n';
#define no cout << "No" << '\n';
#define kotae cout<<ans<<'\n';
#define dame { puts("-1"); return;}
#define dame0 { puts("0"); return;}
#define yn {puts("Yes");}else{puts("No");}
#define db cout<<'@'<<endl;
#define el cout<<'\n';
#define en '\n';
#define pc(x) __builtin_popcount(x)
#define pcl(x) __builtin_popcountll(x)
#define pb push_back
#define eb emplace_back
#define pob pop_back();
#define pof pop_front();
using b128=__int128_t;
using ll=long long;
using ull=unsigned long long;
using Pii=pair<int,int>;
using Pil=pair<int,ll>;
using Pli=pair<ll,int>;
using Pll=pair<ll,ll>;
using Pci=pair<char,int>;
using Pcl=pair<char,ll>;
template <typename T>
using pqg = priority_queue<T,vector<T>,greater<T>>;
using vi=vector<int>;
using vi2=vector<vector<int>>;
using vi3=vector<vector<vector<int>>>;
using vl=vector<ll>;
using vl2=vector<vector<ll>>;
using vl3=vector<vector<vector<ll>>>;
using vs=vector<string>;
using vpii=vector<Pii>;
using vpii2=vector<vector<Pii>>;
using vpil=vector<Pil>;
using vpli=vector<Pli>;
using vpll=vector<Pll>;
using vpll=vector<Pll>;
using vpci=vector<Pci>;
using vpcl=vector<Pcl>;
using Ti=tuple<int,int,int>;
using vti=vector<Ti>;
void coutdouble(double x) { printf("%.10f\n", x); }
void coutvi(vi vec) { for (int k : vec)cout << k << ' '; cout << endl; return; }
void coutvl(vl vec) { for (ll k : vec)cout << k << ' '; cout << endl; return; }
void coutseti(set<int> st) { for (int k : st)cout << k << ' '; cout << endl; return; }
void coutsetl(set<ll> st) { for (ll k : st)cout << k << ' '; cout << endl; return; }
void chmax(int &a, int b){ a = max(a, b); return;}
void chmin(int &a, int b){ a = min(a, b); return;}
void chmaxl(ll &a, ll b){ a = max(a, b); return;}
void chminl(ll &a, ll b){ a = min(a, b); return;}
void rev(vi &a){ reverse(all(a)); return;}
template <typename T>
void srt(T &a){ sort(all(a)); return;}
template <typename T>
void srtr(T &a){ sort(a.rbegin(),a.rend()); return;}
ll tousa(ll a, ll n, ll d) { return (2*a + (n-1)*d)*n/2;}
ll touhi(ll a, ll n, ll r) { ll sum = 1, ar = r, nr = n; while(nr){if(nr%2) sum *= ar; ar*= ar; nr/= 2;} return a*(sum-1)/(r-1);}
using mint = modint998244353;
using vm=vector<mint>;
istream& operator>>(istream& is, mint& a) { long long x; is >> x; a = x; return is; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.val();}

void solve();

int main() {  

  int t = 1;
  //cin >> t;
  rep(i,t) solve();

  return 0;
}
void solve() { 

  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 = iINF;
  for(int i = r1; i <= r2; i++){
    for(int j = c1; j <= c2; j++){
      int now = 0;
      now += abs(a-i) + abs(b-j);
      now += abs(i-p) + abs(j-q);
      now += abs(p-a) + abs(q-b);
      chmin(ans,now);
    }
  }
  kotae
  return;
}
0