結果

問題 No.323 yuki国
ユーザー btkbtk
提出日時 2015-12-17 10:08:21
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 184 ms / 5,000 ms
コード長 1,337 bytes
コンパイル時間 1,207 ms
コンパイル使用メモリ 148,840 KB
実行使用メモリ 12,884 KB
最終ジャッジ日時 2023-09-10 21:21:18
合計ジャッジ時間 5,107 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
12,672 KB
testcase_01 AC 9 ms
12,668 KB
testcase_02 AC 9 ms
12,576 KB
testcase_03 AC 12 ms
12,660 KB
testcase_04 AC 9 ms
12,884 KB
testcase_05 AC 10 ms
12,656 KB
testcase_06 AC 10 ms
12,756 KB
testcase_07 AC 9 ms
12,592 KB
testcase_08 AC 116 ms
12,764 KB
testcase_09 AC 118 ms
12,620 KB
testcase_10 AC 9 ms
12,592 KB
testcase_11 AC 9 ms
12,592 KB
testcase_12 AC 9 ms
12,592 KB
testcase_13 AC 123 ms
12,720 KB
testcase_14 AC 124 ms
12,680 KB
testcase_15 AC 43 ms
12,616 KB
testcase_16 AC 121 ms
12,704 KB
testcase_17 AC 147 ms
12,708 KB
testcase_18 AC 42 ms
12,660 KB
testcase_19 AC 82 ms
12,644 KB
testcase_20 AC 179 ms
12,624 KB
testcase_21 AC 179 ms
12,688 KB
testcase_22 AC 184 ms
12,680 KB
testcase_23 AC 183 ms
12,772 KB
testcase_24 AC 49 ms
12,672 KB
testcase_25 AC 51 ms
12,640 KB
testcase_26 AC 154 ms
12,776 KB
testcase_27 AC 153 ms
12,616 KB
testcase_28 AC 146 ms
12,676 KB
testcase_29 AC 139 ms
12,672 KB
testcase_30 AC 9 ms
12,620 KB
testcase_31 AC 9 ms
12,612 KB
testcase_32 AC 9 ms
12,584 KB
testcase_33 AC 9 ms
12,576 KB
testcase_34 AC 10 ms
12,584 KB
testcase_35 AC 9 ms
12,648 KB
testcase_36 AC 9 ms
12,732 KB
testcase_37 AC 9 ms
12,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL mod=1e9+7;

struct UNKO{
    int r,c,cnt;
    UNKO(int _r,int _c,int _cnt){r=_r,c=_c,cnt=_cnt;}
    UNKO(){r=c=cnt=0;}
};
int akichi[52][52];
bool dp[52][52][3501];
const int INF=-(1e5);
const int dir[5]={-1,0,1,0,-1};
inline bool inner(int l,int n,int r){
    return(l<=n&&n<=r);
}
int main() {
    for(int i = 0; i < 52; i++)
        for(int j = 0; j < 52; j++){
            akichi[i][j]=INF;
            for(int k = 0; k < 3501; k++)
                dp[i][j][k]=false;
            }
    int R,C;cin>>R>>C;
    int A,sr,sc;cin>>A>>sr>>sc;
    int B,gr,gc;cin>>B>>gr>>gc;
    for(int i = 0; i < R; i++)
        for(int j = 0; j < C; j++){
            char c;cin>>c;
            if(c=='*')akichi[i+1][j+1]=1;
            else akichi[i+1][j+1]=-1;

        }
    queue<UNKO> que;
    que.push(UNKO(sr+1,sc+1,A));
    dp[sr+1][sc+1][A]=true;
    while(que.empty()==false){
        auto v=que.front();que.pop();
        for(int i=0;i<4;i++){
            int nr=v.r+dir[i],nc=v.c+dir[i+1],ncnt=v.cnt+akichi[nr][nc];
            if(inner(1,ncnt,3500)&&dp[nr][nc][ncnt]==false){
                dp[nr][nc][ncnt]=true;
                que.push(UNKO(nr,nc,ncnt));
            }
        }
    }
    if(dp[gr+1][gc+1][B])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}
0