結果

問題 No.323 yuki国
ユーザー kimiyukikimiyuki
提出日時 2016-04-19 18:15:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 880 ms / 5,000 ms
コード長 1,240 bytes
コンパイル時間 949 ms
コンパイル使用メモリ 88,576 KB
実行使用メモリ 39,000 KB
最終ジャッジ日時 2023-09-10 21:28:52
合計ジャッジ時間 14,115 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
5,028 KB
testcase_01 AC 5 ms
4,988 KB
testcase_02 AC 7 ms
6,372 KB
testcase_03 AC 30 ms
9,412 KB
testcase_04 AC 5 ms
4,376 KB
testcase_05 AC 10 ms
6,320 KB
testcase_06 AC 4 ms
4,380 KB
testcase_07 AC 8 ms
6,996 KB
testcase_08 AC 624 ms
38,788 KB
testcase_09 AC 619 ms
38,796 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 653 ms
38,680 KB
testcase_14 AC 649 ms
38,836 KB
testcase_15 AC 162 ms
38,696 KB
testcase_16 AC 605 ms
38,692 KB
testcase_17 AC 748 ms
38,848 KB
testcase_18 AC 236 ms
19,632 KB
testcase_19 AC 451 ms
30,932 KB
testcase_20 AC 857 ms
38,728 KB
testcase_21 AC 875 ms
38,732 KB
testcase_22 AC 880 ms
38,736 KB
testcase_23 AC 862 ms
39,000 KB
testcase_24 AC 169 ms
38,804 KB
testcase_25 AC 175 ms
38,748 KB
testcase_26 AC 768 ms
38,684 KB
testcase_27 AC 727 ms
38,804 KB
testcase_28 AC 797 ms
38,784 KB
testcase_29 AC 751 ms
38,736 KB
testcase_30 AC 6 ms
5,588 KB
testcase_31 AC 4 ms
4,376 KB
testcase_32 AC 6 ms
5,064 KB
testcase_33 AC 4 ms
4,380 KB
testcase_34 AC 7 ms
4,964 KB
testcase_35 AC 3 ms
4,380 KB
testcase_36 AC 6 ms
5,064 KB
testcase_37 AC 8 ms
6,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <queue>
#include <tuple>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
using namespace std;
const int lim = 10000;
const int dy[4] = { -1, 1, 0, 0 };
const int dx[4] = { 0, 0, 1, -1 };
int main() {
    int h, w; cin >> h >> w;
    int a, sy, sx; cin >> a >> sy >> sx;
    int b, gy, gx; cin >> b >> gy >> gx;
    vector<string> m(h); repeat (y,h) cin >> m[y];
    vector<vector<vector<bool> > > used(lim, vector<vector<bool> >(h, vector<bool>(w)));
    queue<tuple<int,int,int> > que;
    que.push(make_tuple(a, sy, sx));
    used[a][sy][sx] = true;
    while (not que.empty()) {
        int c, y, x; tie(c, y, x) = que.front(); que.pop();
        repeat (i,4) {
            int ny = y + dy[i];
            int nx = x + dx[i];
            if (0 <= ny and ny < h and 0 <= nx and nx < w) {
                int nc = c + (m[ny][nx] == '*' ? 1 : -1);
                if (1 <= nc and nc < lim) {
                    if (not used[nc][ny][nx]) {
                        used[nc][ny][nx] = true;
                        que.push(make_tuple(nc, ny, nx));
                    }
                }
            }
        }
    }
    cout << (used[b][gy][gx] ? "Yes" : "No") << endl;
    return 0;
}
0