結果

問題 No.323 yuki国
ユーザー parukiparuki
提出日時 2016-06-29 11:58:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 390 ms / 5,000 ms
コード長 1,437 bytes
コンパイル時間 1,793 ms
コンパイル使用メモリ 173,468 KB
実行使用メモリ 12,320 KB
最終ジャッジ日時 2023-09-10 21:34:30
合計ジャッジ時間 5,450 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
11,868 KB
testcase_01 AC 5 ms
11,912 KB
testcase_02 AC 5 ms
11,880 KB
testcase_03 AC 5 ms
11,876 KB
testcase_04 AC 5 ms
11,880 KB
testcase_05 AC 6 ms
11,860 KB
testcase_06 AC 6 ms
11,872 KB
testcase_07 AC 5 ms
12,200 KB
testcase_08 AC 198 ms
12,096 KB
testcase_09 AC 67 ms
12,280 KB
testcase_10 AC 5 ms
11,876 KB
testcase_11 AC 5 ms
11,976 KB
testcase_12 AC 5 ms
11,972 KB
testcase_13 AC 65 ms
11,936 KB
testcase_14 AC 199 ms
11,992 KB
testcase_15 AC 59 ms
12,000 KB
testcase_16 AC 130 ms
12,320 KB
testcase_17 AC 77 ms
11,980 KB
testcase_18 AC 6 ms
12,128 KB
testcase_19 AC 154 ms
12,060 KB
testcase_20 AC 8 ms
12,016 KB
testcase_21 AC 390 ms
12,168 KB
testcase_22 AC 35 ms
12,116 KB
testcase_23 AC 389 ms
12,124 KB
testcase_24 AC 12 ms
12,084 KB
testcase_25 AC 84 ms
12,032 KB
testcase_26 AC 12 ms
12,080 KB
testcase_27 AC 279 ms
12,208 KB
testcase_28 AC 88 ms
11,964 KB
testcase_29 AC 86 ms
12,064 KB
testcase_30 AC 5 ms
11,908 KB
testcase_31 AC 5 ms
11,900 KB
testcase_32 AC 5 ms
12,104 KB
testcase_33 AC 5 ms
11,876 KB
testcase_34 AC 5 ms
12,032 KB
testcase_35 AC 5 ms
11,900 KB
testcase_36 AC 5 ms
12,192 KB
testcase_37 AC 5 ms
11,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
const int DY[] = {-1,0,1,0};
const int DX[] = {0,1,0,-1};

typedef tuple<int, int, int> T;
int H, W;
bool vis[50][50][3501];
int A, SY, SX, B, GY, GX;
string M[50];

bool solve(){
    MEM(vis, 0);
    queue<T> Q;
    Q.push(T(A, SY, SX));
    while(sz(Q)){
        int tama, y, x;
        tie(tama, y, x) = Q.front();
        Q.pop();
        if(vis[y][x][tama])continue;
        vis[y][x][tama] = 1;
        if(y == GY&&x == GX&&tama == B)return 1;

        rep(i, 4){
            int ny = y + DY[i], nx = x + DX[i], ntama = tama;
            if(ny < 0 || ny>=H || nx<0 || nx>=W)continue;
            if(M[ny][nx] == '*')ntama++;
            else ntama--;
            if(ntama <= 0 || ntama >= 3501)continue;
            Q.push(T(ntama, ny, nx));
        }
    }
    return 0;
}

int main(){
    while(cin >> H >> W >> A >> SY >> SX >> B >> GY >> GX){
        rep(y, H)cin >> M[y];
        puts(solve() ? "Yes" : "No");
    }
}
0