結果

問題 No.323 yuki国
ユーザー ayame_pyayame_py
提出日時 2016-01-04 01:50:53
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,349 bytes
コンパイル時間 1,542 ms
コンパイル使用メモリ 173,508 KB
実行使用メモリ 30,064 KB
最終ジャッジ日時 2023-10-19 14:58:02
合計ジャッジ時間 7,300 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 9 ms
9,268 KB
testcase_06 AC 7 ms
8,508 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 RE -
testcase_09 AC 116 ms
15,620 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 6 ms
7,640 KB
testcase_12 AC 6 ms
7,640 KB
testcase_13 AC 104 ms
14,748 KB
testcase_14 RE -
testcase_15 AC 86 ms
12,724 KB
testcase_16 AC 229 ms
26,924 KB
testcase_17 AC 104 ms
14,020 KB
testcase_18 AC 4 ms
4,348 KB
testcase_19 RE -
testcase_20 AC 6 ms
4,392 KB
testcase_21 RE -
testcase_22 AC 40 ms
6,772 KB
testcase_23 RE -
testcase_24 AC 12 ms
4,724 KB
testcase_25 AC 109 ms
13,876 KB
testcase_26 AC 12 ms
4,716 KB
testcase_27 RE -
testcase_28 AC 130 ms
14,936 KB
testcase_29 AC 129 ms
14,960 KB
testcase_30 AC 2 ms
4,348 KB
testcase_31 AC 7 ms
8,460 KB
testcase_32 AC 7 ms
8,716 KB
testcase_33 AC 7 ms
8,440 KB
testcase_34 AC 8 ms
8,768 KB
testcase_35 AC 1 ms
4,348 KB
testcase_36 AC 8 ms
8,732 KB
testcase_37 AC 2 ms
4,348 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[2600][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(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;
    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 << endl;
        if(dist[s.size][s.y][s.x]) 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]) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    
    return 0;
}
0