結果
| 問題 | No.3504 Insert Maze |
| コンテスト | |
| ユーザー |
YuukunA
|
| 提出日時 | 2026-04-18 18:15:12 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 91 ms / 2,000 ms |
| コード長 | 870 bytes |
| 記録 | |
| コンパイル時間 | 3,650 ms |
| コンパイル使用メモリ | 336,060 KB |
| 実行使用メモリ | 7,808 KB |
| 最終ジャッジ日時 | 2026-04-18 18:15:24 |
| 合計ジャッジ時間 | 9,632 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 85 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int H, W;
cin >> H >> W;
vector<string> C(H);
for (auto &s : C) cin >> s;
const int INF = 1e9;
int HH = 2 * H - 1, WW = 2 * W - 1;
vector<int> a(WW, INF), b(WW, INF), c(WW);
for (int i = 0; i < HH; i++) {
fill(c.begin(), c.end(), INF);
for (int j = 0; j < WW; j++) {
if (i % 2 == 0 && j % 2 == 0 && C[i / 2][j / 2] == '#') continue;
int v = i || j ? INF : 0;
if (i) v = min(v, b[j] + 1);
if (j) v = min(v, c[j - 1] + 1);
if (i >= 2 && i % 2 == 0) v = min(v, a[j] + 1);
if (j >= 2 && j % 2 == 0) v = min(v, c[j - 2] + 1);
c[j] = v;
}
a.swap(b);
b.swap(c);
}
cout << b.back() << '\n';
}
YuukunA