結果

問題 No.2646 Cycle Maze
ユーザー umezoumezo
提出日時 2024-02-26 04:25:41
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,145 ms / 2,500 ms
コード長 1,067 bytes
コンパイル時間 3,301 ms
コンパイル使用メモリ 255,636 KB
実行使用メモリ 99,328 KB
最終ジャッジ日時 2024-02-26 04:25:59
合計ジャッジ時間 14,190 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 AC 2 ms
6,548 KB
testcase_04 AC 2 ms
6,548 KB
testcase_05 AC 2 ms
6,548 KB
testcase_06 AC 2 ms
6,548 KB
testcase_07 AC 2 ms
6,548 KB
testcase_08 AC 2 ms
6,548 KB
testcase_09 AC 2 ms
6,548 KB
testcase_10 AC 2 ms
6,548 KB
testcase_11 AC 2 ms
6,548 KB
testcase_12 AC 2 ms
6,548 KB
testcase_13 AC 2 ms
6,548 KB
testcase_14 AC 2 ms
6,548 KB
testcase_15 AC 2 ms
6,548 KB
testcase_16 AC 2 ms
6,548 KB
testcase_17 AC 2 ms
6,548 KB
testcase_18 AC 2 ms
6,548 KB
testcase_19 AC 2 ms
6,548 KB
testcase_20 AC 2 ms
6,548 KB
testcase_21 AC 2 ms
6,548 KB
testcase_22 AC 2 ms
6,548 KB
testcase_23 AC 2 ms
6,548 KB
testcase_24 AC 2 ms
6,548 KB
testcase_25 AC 301 ms
28,416 KB
testcase_26 AC 188 ms
20,608 KB
testcase_27 AC 198 ms
25,472 KB
testcase_28 AC 37 ms
7,424 KB
testcase_29 AC 345 ms
29,184 KB
testcase_30 AC 223 ms
20,480 KB
testcase_31 AC 130 ms
18,048 KB
testcase_32 AC 2 ms
6,548 KB
testcase_33 AC 16 ms
8,064 KB
testcase_34 AC 41 ms
13,056 KB
testcase_35 AC 158 ms
18,944 KB
testcase_36 AC 18 ms
8,064 KB
testcase_37 AC 59 ms
16,256 KB
testcase_38 AC 34 ms
6,548 KB
testcase_39 AC 216 ms
20,224 KB
testcase_40 AC 87 ms
11,136 KB
testcase_41 AC 156 ms
18,048 KB
testcase_42 AC 17 ms
6,548 KB
testcase_43 AC 18 ms
6,548 KB
testcase_44 AC 65 ms
8,832 KB
testcase_45 AC 256 ms
35,328 KB
testcase_46 AC 291 ms
45,312 KB
testcase_47 AC 1,145 ms
91,264 KB
testcase_48 AC 247 ms
37,760 KB
testcase_49 AC 1,061 ms
93,056 KB
testcase_50 AC 303 ms
50,432 KB
testcase_51 AC 601 ms
72,960 KB
testcase_52 AC 720 ms
78,080 KB
testcase_53 AC 1,057 ms
99,328 KB
testcase_54 AC 1,012 ms
99,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;

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

const int k=2520;
int dh[]={1,0,0,0,-1};
int dw[]={0,1,0,-1,0};

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  int h,w,t;
  cin>>h>>w>>t;
  int sy,sx,gy,gx;
  cin>>sy>>sx>>gy>>gx;
  sy--,sx--,gy--,gx--;
  vector<string> S(h);
  rep(i,h) cin>>S[i];
  vector<vector<int>> A(h,vector<int>(w));
  rep(i,h) rep(j,w) A[i][j]=S[i][j]-'0';
  
  auto f=[&](int i,int j,int l){
    return (A[i][j]-l+k)%(A[i][j]+1);
  };
  
  vector<vector<vector<int>>> dp(h,vector<vector<int>>(w,vector<int>(t)));
  dp[sy][sx][0]=1;
  for(int l=0;l<t-1;l++){
    rep(i,h) rep(j,w){
      if(dp[i][j][l]==0) continue;
      rep(m,5){
        int ni=i+dh[m];
        int nj=j+dw[m];
        if(ni<0 || nj<0 || ni>=h || nj>=w) continue;
        if(f(ni,nj,l+1)!=0) dp[ni][nj][l+1]=1;
      }
    }
  }
  rep(l,t){
    if(dp[gy][gx][l]){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;

  return 0;
}
0