結果

問題 No.323 yuki国
ユーザー betit0919betit0919
提出日時 2020-05-09 17:02:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 214 ms / 5,000 ms
コード長 1,784 bytes
コンパイル時間 1,372 ms
コンパイル使用メモリ 126,152 KB
実行使用メモリ 4,972 KB
最終ジャッジ日時 2023-09-20 01:43:17
合計ジャッジ時間 6,599 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 5 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 134 ms
4,376 KB
testcase_09 AC 133 ms
4,416 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 127 ms
4,380 KB
testcase_14 AC 136 ms
4,380 KB
testcase_15 AC 38 ms
4,564 KB
testcase_16 AC 127 ms
4,772 KB
testcase_17 AC 160 ms
4,376 KB
testcase_18 AC 46 ms
4,380 KB
testcase_19 AC 94 ms
4,380 KB
testcase_20 AC 206 ms
4,772 KB
testcase_21 AC 210 ms
4,836 KB
testcase_22 AC 214 ms
4,848 KB
testcase_23 AC 207 ms
4,972 KB
testcase_24 AC 45 ms
4,572 KB
testcase_25 AC 47 ms
4,380 KB
testcase_26 AC 172 ms
4,376 KB
testcase_27 AC 164 ms
4,380 KB
testcase_28 AC 169 ms
4,380 KB
testcase_29 AC 153 ms
4,380 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 1 ms
4,376 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int H,W,A,Si,Sj,B,Gi,Gj;
  cin>>H>>W>>A>>Si>>Sj>>B>>Gi>>Gj;
  vector<string>M(H);
  REP(i,H)cin>>M[i];

  vector<vector<vector<bool>>> ans(H, vector<vector<bool>>(W, vector<bool>(4000)));

  queue<tuple<int,int,int>> q;
  q.push(tie(Si,Sj,A));

  const pair<int,int> moves[] = {
    {-1,0}, {1,0}, {0,-1}, {0,1},
  };

  while(!q.empty()){
    tuple<int,int,int>cur=q.front();q.pop();
    for(auto &move:moves){
      int x=get<0>(cur);
      int y=get<1>(cur);
      int s=get<2>(cur);
      int nextx=x+move.first;
      int nexty=y+move.second;
      if(nextx<0 || nexty<0 || nextx>=H || nexty>=W){
        continue;
      }
      int nexts=s+(M[nextx][nexty]=='*'?1:-1);
      if(nexts<=0 || nexts>=3800){
        continue;
      }
      if(!ans[nextx][nexty][nexts]){
        ans[nextx][nexty][nexts]=true;
        q.push(tie(nextx,nexty,nexts));
      }
    }
  }
  cout<<(ans[Gi][Gj][B]?"Yes":"No")<<endl;
}
0