結果

問題 No.323 yuki国
ユーザー 37kt_37kt_
提出日時 2016-04-25 10:51:08
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 165 ms / 5,000 ms
コード長 841 bytes
コンパイル時間 1,378 ms
コンパイル使用メモリ 153,516 KB
実行使用メモリ 9,592 KB
最終ジャッジ日時 2023-09-10 21:28:15
合計ジャッジ時間 5,055 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 4 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 108 ms
9,512 KB
testcase_09 AC 109 ms
9,548 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 108 ms
9,540 KB
testcase_14 AC 109 ms
9,536 KB
testcase_15 AC 51 ms
9,548 KB
testcase_16 AC 108 ms
9,576 KB
testcase_17 AC 129 ms
9,580 KB
testcase_18 AC 38 ms
5,380 KB
testcase_19 AC 76 ms
7,248 KB
testcase_20 AC 159 ms
9,532 KB
testcase_21 AC 162 ms
9,592 KB
testcase_22 AC 165 ms
9,588 KB
testcase_23 AC 162 ms
9,588 KB
testcase_24 AC 58 ms
9,500 KB
testcase_25 AC 62 ms
9,556 KB
testcase_26 AC 140 ms
9,552 KB
testcase_27 AC 135 ms
9,516 KB
testcase_28 AC 135 ms
9,532 KB
testcase_29 AC 134 ms
9,516 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 1 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 1 ms
4,380 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

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

int n, m;
int a, sx, sy, b, gx, gy;
string c[50];
bool vis[50][50][2510];

int main(){
  cin >> n >> m >> a >> sx >> sy >> b >> gx >> gy;
  for (int i = 0; i < n; i++) cin >> c[i];

  queue<tuple<int, int, int>> q;
  vis[sx][sy][a] = true;
  q.emplace(sx, sy, a);
  while (q.size()){
    int x, y, s;
    tie(x, y, s) = q.front();
    q.pop();
    for (int i = 0; i < 4; i++){
      int nx = x + dx[i];
      int ny = y + dy[i];
      if (nx < 0 || n <= nx || ny < 0 || m <= ny) continue;
      int ns = s + (c[nx][ny] == '*' ? 1 : -1);
      if (ns <= 0 || ns > 2510) continue;
      if (vis[nx][ny][ns]) continue;
      vis[nx][ny][ns] = true;
      q.emplace(nx, ny, ns);
    }
  }

  cout << (vis[gx][gy][b] ? "Yes\n" : "No\n");
}
0