結果

問題 No.240 ナイト散歩
ユーザー mmn15277198mmn15277198
提出日時 2021-04-18 16:30:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,448 bytes
コンパイル時間 1,493 ms
コンパイル使用メモリ 166,664 KB
実行使用メモリ 814,228 KB
最終ジャッジ日時 2023-09-17 07:48:39
合計ジャッジ時間 4,221 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 MLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main() {
    int h , w;
    cin >> h >> w;
    int y1 , x1;
    cin >> y1 >> x1;
    y1--;
    x1--;
    int y2 , x2;
    cin >> y2 >> x2;
    y2--;
    x2--;
    vector<string> s(h);
    for (int i = 0 ; i < h; i++) cin >> s[i];
    cout << abs(x1 - x2) + abs(y1 - y2) << endl;
    /*
    queue<int> qx;
    queue<int> qy;
    qx.push(x1);
    qy.push(y1);
    s[y1][x1] = 'A';
    vector<vector<int>> a(h , vector<int>(w , 0));
    while (!qx.empty()) {
        int x = qx.front();
        int y = qy.front();
        qx.pop();
        qy.pop();
        if (x == x2 && y == y2) {
            cout << a[y][x] << endl;
            return 0;
        }
        if (x + 1 < w && s[y][x + 1] == '.') {
            qx.push(x + 1);
            qy.push(y);
            s[y][x + 1] = 'A';
            a[y][x + 1] = a[y][x] + 1;
        }
        if (x - 1 >= 0 && s[y][x - 1] == '.') {
            qx.push(x - 1);
            qy.push(y);
            s[y][x - 1] = 'A';
            a[y][x - 1] = a[y][x] + 1;
        }
        if (y + 1 < h && s[y + 1][x] == '.') {
            qx.push(x);
            qy.push(y + 1);
            s[y + 1][x] = 'A';
            a[y + 1][x] = a[y][x] + 1;
        }
        if (y - 1 >= 0 && s[y - 1][x] == '.') {
            qx.push(x);
            qy.push(y - 1);
            s[y - 1][x] = 'A';
            a[y - 1][x] = a[y][x] + 1;
        }
    }
    */
    return 0;
}
0