結果

問題 No.323 yuki国
ユーザー face4face4
提出日時 2019-03-18 13:49:57
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 391 ms / 5,000 ms
コード長 1,108 bytes
コンパイル時間 691 ms
コンパイル使用メモリ 76,108 KB
実行使用メモリ 12,168 KB
最終ジャッジ日時 2023-09-25 09:49:47
合計ジャッジ時間 7,290 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 7 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 203 ms
11,888 KB
testcase_09 AC 204 ms
11,944 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 211 ms
11,940 KB
testcase_14 AC 217 ms
11,928 KB
testcase_15 AC 86 ms
11,920 KB
testcase_16 AC 266 ms
11,944 KB
testcase_17 AC 283 ms
11,964 KB
testcase_18 AC 77 ms
5,916 KB
testcase_19 AC 161 ms
8,660 KB
testcase_20 AC 381 ms
11,948 KB
testcase_21 AC 391 ms
11,988 KB
testcase_22 AC 388 ms
12,168 KB
testcase_23 AC 377 ms
12,008 KB
testcase_24 AC 97 ms
11,912 KB
testcase_25 AC 94 ms
11,916 KB
testcase_26 AC 309 ms
11,928 KB
testcase_27 AC 328 ms
12,012 KB
testcase_28 AC 274 ms
11,916 KB
testcase_29 AC 260 ms
11,880 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
using namespace std;
#define inRange(x,a,b) (a <= x && x < b)
int di[8] = {0,0,1,-1,1,1,-1,-1};
int dj[8] = {1,-1,0,0,1,-1,1,-1};

int main(){
    int h, w, a, si, sj, b, gi, gj;
    cin >> h >> w >> a >> si >> sj >> b >> gi >> gj;
    char mat[h][w];
    for(int i = 0; i < h*w; i++)    cin >> mat[i/w][i%w];
    bool dp[h][w][3500+1];
    memset(dp, 0, sizeof(dp));
    queue<pair<int,pair<int,int>>> q;
    q.push({a, {si,sj}});
    while(!q.empty()){
        auto p = q.front(); q.pop();
        int i = p.second.first, j = p.second.second, c = p.first;
        if(dp[i][j][c]) continue;
        dp[i][j][c] = true;
        if(c == 0)  continue;
        for(int k = 0; k < 4; k++){
            int ni = i+di[k], nj = j+dj[k];
            if(!inRange(ni,0,h) || !inRange(nj,0,w) || c+(mat[ni][nj]=='*'?1:-1) > 3500 || dp[ni][nj][c+(mat[ni][nj]=='*'?1:-1)]){
                continue;
            }
            q.push({c+(mat[ni][nj]=='*'?1:-1), {ni,nj}});
        }
    }
    cout << (dp[gi][gj][b]?"Yes":"No") << endl;
    return 0;
}
0