結果

問題 No.323 yuki国
ユーザー koyoprokoyopro
提出日時 2020-06-12 02:20:35
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,840 bytes
コンパイル時間 1,620 ms
コンパイル使用メモリ 149,764 KB
実行使用メモリ 13,436 KB
最終ジャッジ日時 2023-09-06 08:51:39
合計ジャッジ時間 6,767 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 6 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 WA -
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 171 ms
13,160 KB
testcase_09 AC 175 ms
13,172 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 176 ms
13,180 KB
testcase_14 AC 176 ms
13,192 KB
testcase_15 AC 57 ms
13,252 KB
testcase_16 AC 169 ms
13,284 KB
testcase_17 AC 224 ms
13,192 KB
testcase_18 AC 55 ms
6,456 KB
testcase_19 AC 116 ms
9,584 KB
testcase_20 AC 274 ms
13,264 KB
testcase_21 AC 276 ms
13,372 KB
testcase_22 AC 275 ms
13,296 KB
testcase_23 AC 265 ms
13,212 KB
testcase_24 AC 66 ms
13,436 KB
testcase_25 AC 67 ms
13,424 KB
testcase_26 AC 230 ms
13,196 KB
testcase_27 AC 232 ms
13,236 KB
testcase_28 AC 219 ms
13,264 KB
testcase_29 AC 213 ms
13,152 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)
#if DEBUG
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...) /* ... */
#endif

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 50
#define MAX 40
#else
#define SIZE 50
#define MAX 4000
#endif

int H,W;
bool DP[SIZE][SIZE][MAX];

struct Pos {
    int v,h,w;
};
Pos P[2];
int dxy[] = {1,0,-1,0,1};
string S[SIZE];

void solve() {
    cin>>H>>W;
    REP(i,2)cin>>P[i].v>>P[i].h>>P[i].w;
    REP(i,H)cin>>S[i];
    queue<Pos> que;
    que.push(P[0]);
    while(que.size()) {
        auto p = que.front();
        que.pop();
        REP(i,4) {
            int nh = p.h+dxy[i], nw = p.w+dxy[i+1];
            if (nh<0||nw<0||nh>=H||nw>=W) continue;
            int nv = p.v + (S[nh][nw]=='.' ? -1 : 1);
            if (nv < 0 || MAX <= nv || DP[nh][nw][nv]) continue;
            debug("(%lld,%lld)->%lld\n",nh,nw,nv);
            DP[nh][nw][nv] = 1;
            que.push({nv,nh,nw});
        }
    }
    if (DP[P[1].h][P[1].w][P[1].v]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

0