結果

問題 No.323 yuki国
ユーザー tokizotokizo
提出日時 2019-04-12 16:56:28
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 173 ms / 5,000 ms
コード長 1,408 bytes
コンパイル時間 1,706 ms
コンパイル使用メモリ 171,096 KB
実行使用メモリ 9,920 KB
最終ジャッジ日時 2023-10-12 07:31:56
合計ジャッジ時間 5,595 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,372 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 2 ms
4,368 KB
testcase_03 AC 5 ms
4,368 KB
testcase_04 AC 2 ms
4,372 KB
testcase_05 AC 2 ms
4,368 KB
testcase_06 AC 2 ms
4,368 KB
testcase_07 AC 2 ms
4,372 KB
testcase_08 AC 102 ms
9,896 KB
testcase_09 AC 102 ms
9,760 KB
testcase_10 AC 2 ms
4,372 KB
testcase_11 AC 1 ms
4,368 KB
testcase_12 AC 1 ms
4,372 KB
testcase_13 AC 106 ms
9,848 KB
testcase_14 AC 106 ms
9,684 KB
testcase_15 AC 50 ms
9,672 KB
testcase_16 AC 104 ms
9,692 KB
testcase_17 AC 137 ms
9,776 KB
testcase_18 AC 39 ms
5,592 KB
testcase_19 AC 77 ms
7,380 KB
testcase_20 AC 169 ms
9,800 KB
testcase_21 AC 172 ms
9,920 KB
testcase_22 AC 173 ms
9,872 KB
testcase_23 AC 171 ms
9,692 KB
testcase_24 AC 60 ms
9,668 KB
testcase_25 AC 63 ms
9,680 KB
testcase_26 AC 143 ms
9,916 KB
testcase_27 AC 139 ms
9,788 KB
testcase_28 AC 138 ms
9,844 KB
testcase_29 AC 130 ms
9,752 KB
testcase_30 AC 2 ms
4,368 KB
testcase_31 AC 2 ms
4,372 KB
testcase_32 AC 2 ms
4,368 KB
testcase_33 AC 2 ms
4,372 KB
testcase_34 AC 2 ms
4,368 KB
testcase_35 AC 2 ms
4,368 KB
testcase_36 AC 2 ms
4,368 KB
testcase_37 AC 2 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef pair<pair<int, int>, int> P;

const int L = 55;
char C[L][L];

bool ok[L][L][2510]; // x, y, snow

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

int h, w, a, b;
int sx, sy, gx, gy;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    cin >> h >> w;
    cin >> a >> sx >> sy;
    cin >> b >> gx >> gy;

    ok[sx][sy][a] = true;

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> C[i][j];
        }
    }

    bool f = false;

    queue<P> q;
    q.push({{sx, sy}, a});
    while(!q.empty()){
        P p = q.front();
        q.pop();
        int x = p.first.first;
        int y = p.first.second;
        int snow = p.second;
        // cout << x << ' ' << y << ' ' << snow << endl;
        
        for(int i = 0; i < 4; i++){
            int nx, ny;
            nx = dx[i] + x;
            ny = dy[i] + y;
            if(nx < 0 or ny < 0 or nx >= h or ny >= w){
                continue;
            }
            int m = (C[nx][ny] == '*' ? 1 : -1) + snow;
            if(m <= 0 or m >= 2510) continue;
            if(ok[nx][ny][m]) continue;
            ok[nx][ny][m] = true;
            if(nx == gx and ny == gy and m == b){
                break;
            }
            q.push({{nx, ny}, m});
        } 
    }

    cout << (ok[gx][gy][b] ? "Yes" : "No") << endl;

    return 0;
}
0