結果

問題 No.323 yuki国
ユーザー h_nosonh_noson
提出日時 2016-06-10 00:35:05
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 79 ms / 5,000 ms
コード長 1,387 bytes
コンパイル時間 554 ms
コンパイル使用メモリ 74,376 KB
実行使用メモリ 6,712 KB
最終ジャッジ日時 2023-09-10 21:31:07
合計ジャッジ時間 3,018 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 47 ms
6,536 KB
testcase_09 AC 47 ms
6,444 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 50 ms
6,520 KB
testcase_14 AC 49 ms
6,712 KB
testcase_15 AC 42 ms
6,452 KB
testcase_16 AC 47 ms
6,548 KB
testcase_17 AC 60 ms
6,708 KB
testcase_18 AC 18 ms
4,384 KB
testcase_19 AC 37 ms
5,388 KB
testcase_20 AC 76 ms
6,468 KB
testcase_21 AC 76 ms
6,528 KB
testcase_22 AC 79 ms
6,616 KB
testcase_23 AC 79 ms
6,444 KB
testcase_24 AC 51 ms
6,476 KB
testcase_25 AC 51 ms
6,476 KB
testcase_26 AC 62 ms
6,472 KB
testcase_27 AC 64 ms
6,712 KB
testcase_28 AC 61 ms
6,432 KB
testcase_29 AC 57 ms
6,476 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 1 ms
4,376 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,s,e) for (i = s; i <= e; i++)
#define rep(i,n) REP (i,0,(int)(n)-1)
#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP (i,(int)(n)-1,0)
#define INF (int)1e8
#define MOD (int)(1e9+7)

typedef long long ll;

bool arrive[50][50][1251];
int dxy[4] = {-1,0,1,0};

int main(void) {
    int i, j, h, w, a, b, si, sj, gi, gj;
    string m[50];
    cin >> h >> w;
    cin >> a >> si >> sj;
    cin >> b >> gi >> gj;
    rep (i,h) cin >> m[i];

    queue<pair<pair<int,int>,int>> q;
    arrive[si][sj][a] = true;
    q.push(make_pair(make_pair(si,sj),a));
    while (!q.empty()) {
        int x = q.front().first.first;
        int y = q.front().first.second;
        int size = q.front().second;
        q.pop();
        rep (i,4) {
            int nx = x + dxy[i];
            int ny = y + dxy[(i+1)%4];
            if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
            int nsize = size + (m[nx][ny] == '*' ? 1 : -1);
            if (nsize > 0 && nsize <= 1250 && !arrive[nx][ny][nsize]) {
                arrive[nx][ny][nsize] = true;
                q.push(make_pair(make_pair(nx,ny),nsize));
            }
        }
    }

    if (arrive[gi][gj][b])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}
0