結果
| 問題 | No.3679 なんかでっかい虫リターンズ |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-05 13:27:47 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.92.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| + 435µs | |
| コード長 | 571 bytes |
| 記録 | |
| コンパイル時間 | 2,276 ms |
| コンパイル使用メモリ | 352,600 KB |
| 実行使用メモリ | 9,720 KB |
| 最終ジャッジ日時 | 2026-09-05 13:28:09 |
| 合計ジャッジ時間 | 3,896 ms |
|
ジャッジサーバーID (参考情報) |
judge4_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int H, W, A, B, R1, C1, R2, C2, P, Q, ans = INT_MAX;
cin >> H >> W >> A >> B >> R1 >> C1 >> R2 >> C2 >> P >> Q;
vector<pair<int, int>> dir = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
auto dist = [&](int nr, int nc, int tr, int tc) -> int {
return abs(nr - tr) + abs(nc - tc);
};
for(int r=R1; r<=R2; r++) for(int c=C1; c<=C2; c++) ans = min(ans, dist(A, B, r, c) + dist(r, c, P, Q) + dist(P, Q, A, B));
cout << ans << endl;
}