結果

問題 No.323 yuki国
ユーザー ayame_pyayame_py
提出日時 2016-01-04 02:26:13
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 573 ms / 5,000 ms
コード長 1,517 bytes
コンパイル時間 1,487 ms
コンパイル使用メモリ 173,596 KB
実行使用メモリ 44,328 KB
最終ジャッジ日時 2023-10-19 14:58:53
合計ジャッジ時間 6,483 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
44,232 KB
testcase_01 AC 12 ms
44,232 KB
testcase_02 AC 12 ms
44,232 KB
testcase_03 AC 13 ms
44,232 KB
testcase_04 AC 12 ms
44,232 KB
testcase_05 AC 14 ms
44,232 KB
testcase_06 AC 13 ms
44,232 KB
testcase_07 AC 12 ms
44,232 KB
testcase_08 AC 326 ms
44,260 KB
testcase_09 AC 105 ms
44,264 KB
testcase_10 AC 13 ms
44,232 KB
testcase_11 AC 13 ms
44,232 KB
testcase_12 AC 13 ms
44,232 KB
testcase_13 AC 98 ms
44,268 KB
testcase_14 AC 325 ms
44,264 KB
testcase_15 AC 108 ms
44,304 KB
testcase_16 AC 247 ms
44,328 KB
testcase_17 AC 113 ms
44,288 KB
testcase_18 AC 14 ms
44,256 KB
testcase_19 AC 206 ms
44,288 KB
testcase_20 AC 17 ms
44,300 KB
testcase_21 AC 573 ms
44,328 KB
testcase_22 AC 55 ms
44,328 KB
testcase_23 AC 568 ms
44,328 KB
testcase_24 AC 23 ms
44,300 KB
testcase_25 AC 132 ms
44,296 KB
testcase_26 AC 23 ms
44,300 KB
testcase_27 AC 469 ms
44,296 KB
testcase_28 AC 130 ms
44,264 KB
testcase_29 AC 128 ms
44,264 KB
testcase_30 AC 12 ms
44,232 KB
testcase_31 AC 12 ms
44,232 KB
testcase_32 AC 13 ms
44,232 KB
testcase_33 AC 13 ms
44,232 KB
testcase_34 AC 13 ms
44,232 KB
testcase_35 AC 12 ms
44,232 KB
testcase_36 AC 13 ms
44,232 KB
testcase_37 AC 13 ms
44,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,n,m) for (int i=n; i<(int)(m); i++)
#define INF 1000000007

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

struct state{int size, y, x;};
// 雪玉のサイズ 縦 横
int dist[4000][51][51];
int H,W,A,Sy,Sx,B,Gy,Gx;
string M[52];
map<char,int> ma;

bool isOK(int size,int y, int x){
    //範囲外
    if(y<0||H<=y||x<0||W<=x) return false;
    //とける
    if(size==1 && M[y][x]=='.') return false;
    //もう探索した
    if(dist[size+ma[M[y][x]]][y][x]==1) return false;
    //大きすぎ
    if(size > H * W + 1200) return false;
    return true;
}

int main(){
    cin >> H >> W;
    cin >> A >> Sy >> Sx;
    cin >> B >> Gy >> Gx;
    REP(i,H){
        cin >> M[i];
    }
    ma['.']=-1;
    ma['*']=1;
    REP(i,4000)REP(j,51)REP(k,51)dist[i][j][k]=0;
    queue<state> que;
    que.push(state{A,Sy,Sx});
    while(que.size()){
        state &s=que.front();que.pop();
        //cout << s.size << " " << s.x << " " << s.y << " " << dist[s.size][s.y][s.x] << endl;
        if(dist[s.size][s.y][s.x]==1) continue;
        else dist[s.size][s.y][s.x]=1;
        if(s.y==Gy && s.x==Gx && s.size==B) break;
        REP(i,4){
            if(isOK(s.size,s.y+dy[i],s.x+dx[i])){
                que.push(state{s.size+ma[M[s.y+dy[i]][s.x+dx[i]]],s.y+dy[i],s.x+dx[i]});
            }
        }
    }
    if(dist[B][Gy][Gx]==1) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    
    return 0;
}
0