結果

問題 No.323 yuki国
ユーザー ayame_pyayame_py
提出日時 2016-01-04 02:30:23
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 618 ms / 5,000 ms
コード長 1,466 bytes
コンパイル時間 1,608 ms
コンパイル使用メモリ 157,616 KB
実行使用メモリ 41,108 KB
最終ジャッジ日時 2023-09-10 21:25:12
合計ジャッジ時間 6,859 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 9 ms
9,036 KB
testcase_06 AC 7 ms
8,272 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 351 ms
40,884 KB
testcase_09 AC 108 ms
15,296 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 6 ms
7,348 KB
testcase_12 AC 6 ms
7,648 KB
testcase_13 AC 96 ms
14,488 KB
testcase_14 AC 332 ms
40,992 KB
testcase_15 AC 106 ms
12,392 KB
testcase_16 AC 244 ms
26,592 KB
testcase_17 AC 115 ms
13,680 KB
testcase_18 AC 4 ms
4,376 KB
testcase_19 AC 228 ms
31,136 KB
testcase_20 AC 7 ms
4,376 KB
testcase_21 AC 618 ms
41,096 KB
testcase_22 AC 49 ms
6,504 KB
testcase_23 AC 612 ms
41,108 KB
testcase_24 AC 14 ms
4,400 KB
testcase_25 AC 137 ms
13,572 KB
testcase_26 AC 14 ms
4,408 KB
testcase_27 AC 507 ms
41,008 KB
testcase_28 AC 131 ms
14,636 KB
testcase_29 AC 131 ms
14,932 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 7 ms
8,216 KB
testcase_32 AC 7 ms
8,476 KB
testcase_33 AC 7 ms
8,216 KB
testcase_34 AC 8 ms
8,524 KB
testcase_35 AC 2 ms
4,384 KB
testcase_36 AC 8 ms
8,492 KB
testcase_37 AC 2 ms
4,376 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;
    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