結果

問題 No.323 yuki国
ユーザー tokizotokizo
提出日時 2019-04-12 16:51:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,393 bytes
コンパイル時間 1,656 ms
コンパイル使用メモリ 171,916 KB
実行使用メモリ 814,492 KB
最終ジャッジ日時 2023-10-12 07:24:06
合計ジャッジ時間 8,357 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 3 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 19 ms
5,364 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 MLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

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;

    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;
        
        ok[x][y][snow] = true;
        if(x == gx and y == gy and snow == b){
            break;
        }
        
        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 or m > b + h * w) continue;
            if(ok[nx][ny][m]) continue;
            q.push({{nx, ny}, m});
        } 
    }

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

    return 0;
}
0