結果

問題 No.323 yuki国
ユーザー ctyl_0ctyl_0
提出日時 2015-12-17 02:49:25
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 481 ms / 5,000 ms
コード長 2,023 bytes
コンパイル時間 1,122 ms
コンパイル使用メモリ 100,124 KB
実行使用メモリ 43,084 KB
最終ジャッジ日時 2023-09-10 21:20:07
合計ジャッジ時間 7,601 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 7 ms
4,540 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 249 ms
42,888 KB
testcase_09 AC 247 ms
42,944 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 252 ms
42,912 KB
testcase_14 AC 273 ms
42,960 KB
testcase_15 AC 92 ms
42,884 KB
testcase_16 AC 274 ms
42,904 KB
testcase_17 AC 307 ms
42,884 KB
testcase_18 AC 73 ms
15,432 KB
testcase_19 AC 180 ms
27,576 KB
testcase_20 AC 477 ms
42,880 KB
testcase_21 AC 481 ms
42,908 KB
testcase_22 AC 479 ms
43,084 KB
testcase_23 AC 475 ms
42,936 KB
testcase_24 AC 111 ms
42,884 KB
testcase_25 AC 104 ms
42,940 KB
testcase_26 AC 340 ms
42,880 KB
testcase_27 AC 373 ms
42,892 KB
testcase_28 AC 323 ms
42,960 KB
testcase_29 AC 314 ms
42,936 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 2 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define var auto
#define mod 1000000007
#define inf 2147483647
#define nil -1
#define mp make_pair
typedef long long ll;
using namespace std;

template <typename T>
inline void output(T a, int p) {
    if(p){
        cout << fixed << setprecision(p)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}
// end of template

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

int main() {
    cin.tie(0);
    // source code
    int H, W, A, Sx, Sy, B, Gx, Gy;
    cin >> H >> W >> A >> Sy >> Sx >> B >> Gy >> Gx;
    vector<string> M(H);
    rep(i, H) cin >> M[i];
    vector<vector<vector<int>>> P(H, vector<vector<int>> (W, vector<int>(bound)));
    
    queue<pair<pair<int, int>, int>> q;
    P[Sy][Sx][A] = 1;
    q.push(mp(mp(Sx, Sy), A));
    while (!q.empty()) {
        var t = q.front();
        var x = t.first.first;
        var y = t.first.second;
        var a = t.second;
        q.pop();
        if (a != 0) {
            rep(i, 4){
                if (x + dx[i] >= 0 && x + dx[i] < W && y + dy[i] >= 0 && y + dy[i] < H && a + 1 < bound) {
                    if (M[y + dy[i]][x + dx[i]] == '*' && P[y + dy[i]][x + dx[i]][a + 1] != 1) {
                        q.push(mp(mp(x + dx[i], y + dy[i]), a + 1));
                        P[y + dy[i]][x + dx[i]][a + 1] = 1;
                    }
                    else if(M[y + dy[i]][x + dx[i]] == '.' && P[y + dy[i]][x + dx[i]][a - 1] != 1){
                        q.push(mp(mp(x + dx[i], y + dy[i]), a - 1));
                        P[y + dy[i]][x + dx[i]][a - 1] = 1;
                    }
                }
            }
        }
    }
    
    output(P[Gy][Gx][B] ? "Yes" : "No", 0);
    
    return 0;
}
0