結果

問題 No.3679 なんかでっかい虫リターンズ
コンテスト
ユーザー haru34829
提出日時 2026-09-05 14:05:48
言語 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
+ 430µs
コード長 642 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,589 ms
コンパイル使用メモリ 353,232 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2026-09-05 14:07:03
合計ジャッジ時間 4,332 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

int main() {
  ll top = 201,bottom = -1,left = 201,right = -1,h,w,a,b,p,q;
  cin >> h >> w >> a >> b;
  vector<pair<ll,ll>> bug(2);
  for(int i = 0;i < 2;i++){
    int tmp1,tmp2;
    cin >> tmp1 >> tmp2;
    bug.at(i) = make_pair(tmp1,tmp2);
  }
  cin >> p >> q;
  ll ans = 10000000000;
  for(int i = bug.at(0).first;i <= bug.at(1).first;i++){
    for(int j = bug.at(0).second;j <= bug.at(1).second;j++){
      ll s = abs(a - p) + abs(b - q);
      s += abs(p - i) + abs(q - j);
      s += abs(a - i) + abs(b - j);
      ans = min(ans,s);
    }
  }
  cout << ans << endl;
}
0