結果

問題 No.323 yuki国
ユーザー iqueue02iqueue02
提出日時 2020-01-17 14:28:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 327 ms / 5,000 ms
コード長 992 bytes
コンパイル時間 1,800 ms
コンパイル使用メモリ 172,152 KB
実行使用メモリ 38,992 KB
最終ジャッジ日時 2023-09-07 22:13:52
合計ジャッジ時間 8,003 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
5,584 KB
testcase_03 AC 7 ms
4,544 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
5,484 KB
testcase_08 AC 250 ms
38,720 KB
testcase_09 AC 240 ms
38,872 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 251 ms
38,732 KB
testcase_14 AC 257 ms
38,744 KB
testcase_15 AC 85 ms
23,100 KB
testcase_16 AC 256 ms
38,724 KB
testcase_17 AC 278 ms
38,772 KB
testcase_18 AC 69 ms
14,852 KB
testcase_19 AC 160 ms
24,996 KB
testcase_20 AC 320 ms
38,992 KB
testcase_21 AC 327 ms
38,804 KB
testcase_22 AC 321 ms
38,744 KB
testcase_23 AC 305 ms
38,748 KB
testcase_24 AC 92 ms
23,020 KB
testcase_25 AC 90 ms
23,180 KB
testcase_26 AC 280 ms
38,740 KB
testcase_27 AC 287 ms
38,816 KB
testcase_28 AC 267 ms
38,756 KB
testcase_29 AC 266 ms
38,732 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
int ok[51][51][3601];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int main(){
  int h, w, a, b;
  int sx, sy, gx, gy;
  cin >> h >> w;
  cin >> a >> sx >> sy;
  cin >> b >> gx >> gy;
  vector<string> s(h);
  rep(i,h) cin >> s[i];

  ok[sx][sy][a] = 1;
  queue<P> que;
  que.push(make_pair(sx*100+sy, a));
  
  while (!que.empty()) {
    auto p = que.front(); que.pop();

    rep(i, 4) {
      int x = p.first / 100 + dx[i];
      int y = p.first % 100 + dy[i];
      if (x < 0 || y < 0 || x >= h || y >= w) continue;
      int cost = p.second + (s[x][y] == '*' ? 1 : -1);
      if (cost <= 0 || cost > 3500) continue;
      if (ok[x][y][cost]) continue;
      ok[x][y][cost] = 1;
      que.push(make_pair(x*100+y, cost));
    }
  }
  if (ok[gx][gy][b]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}
0