結果

問題 No.323 yuki国
ユーザー SSRSSSRS
提出日時 2020-11-11 23:29:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 118 ms / 5,000 ms
コード長 1,149 bytes
コンパイル時間 1,843 ms
コンパイル使用メモリ 182,176 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 00:57:58
合計ジャッジ時間 4,967 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 3 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,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 54 ms
4,376 KB
testcase_09 AC 58 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 61 ms
4,376 KB
testcase_14 AC 57 ms
4,376 KB
testcase_15 AC 50 ms
4,376 KB
testcase_16 AC 55 ms
4,376 KB
testcase_17 AC 72 ms
4,376 KB
testcase_18 AC 23 ms
4,376 KB
testcase_19 AC 43 ms
4,376 KB
testcase_20 AC 116 ms
4,376 KB
testcase_21 AC 117 ms
4,376 KB
testcase_22 AC 118 ms
4,376 KB
testcase_23 AC 111 ms
4,376 KB
testcase_24 AC 70 ms
4,376 KB
testcase_25 AC 66 ms
4,376 KB
testcase_26 AC 79 ms
4,380 KB
testcase_27 AC 85 ms
4,376 KB
testcase_28 AC 73 ms
4,376 KB
testcase_29 AC 74 ms
4,380 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 1 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,376 KB
testcase_37 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
vector<int> dy = {1, 0, -1, 0};
vector<int> dx = {0, 1, 0, -1};
int main(){
  int H, W;
  cin >> H >> W;
  int A, Si, Sj;
  cin >> A >> Si >> Sj;
  int B, Gi, Gj;
  cin >> B >> Gi >> Gj;
  vector<string> M(H);
  for (int i = 0; i < H; i++){
    cin >> M[i];
  }
  vector<vector<vector<bool>>> used(H, vector<vector<bool>>(W, vector<bool>(1200, false)));
  used[Si][Sj][A] = true;
  queue<tuple<int, int, int>> Q;
  Q.push(make_tuple(Si, Sj, A));
  while (!Q.empty()){
    int y = get<0>(Q.front());
    int x = get<1>(Q.front());
    int s = get<2>(Q.front());
    Q.pop();
    for (int i = 0; i < 4; i++){
      int y2 = y + dy[i];
      int x2 = x + dx[i];
      if (0 <= y2 && y2 < H && 0 <= x2 && x2 < W){
        int s2 = s;
        if (M[y2][x2] == '*'){
          s2++;
        } else {
          s2--;
        }
        if (1 <= s2 && s2 < 1200){
          if (!used[y2][x2][s2]){
            used[y2][x2][s2] = true;
            Q.push(make_tuple(y2, x2, s2));
          }
        }
      }
    }
  }
  if (used[Gi][Gj][B]){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
0