結果

問題 No.2646 Cycle Maze
ユーザー umezoumezo
提出日時 2024-02-26 03:28:14
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,297 bytes
コンパイル時間 3,034 ms
コンパイル使用メモリ 255,640 KB
実行使用メモリ 814,336 KB
最終ジャッジ日時 2024-02-26 03:28:45
合計ジャッジ時間 28,030 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
6,676 KB
testcase_01 AC 36 ms
6,676 KB
testcase_02 AC 35 ms
6,676 KB
testcase_03 AC 35 ms
6,676 KB
testcase_04 AC 36 ms
6,676 KB
testcase_05 AC 35 ms
6,676 KB
testcase_06 AC 36 ms
6,676 KB
testcase_07 AC 36 ms
6,676 KB
testcase_08 AC 36 ms
6,676 KB
testcase_09 AC 36 ms
6,676 KB
testcase_10 AC 37 ms
6,676 KB
testcase_11 AC 36 ms
6,676 KB
testcase_12 AC 36 ms
6,676 KB
testcase_13 AC 35 ms
6,676 KB
testcase_14 AC 35 ms
6,676 KB
testcase_15 AC 35 ms
6,676 KB
testcase_16 AC 35 ms
6,676 KB
testcase_17 AC 35 ms
6,676 KB
testcase_18 AC 36 ms
6,676 KB
testcase_19 AC 36 ms
6,676 KB
testcase_20 AC 36 ms
6,676 KB
testcase_21 AC 35 ms
6,676 KB
testcase_22 AC 36 ms
6,676 KB
testcase_23 AC 35 ms
6,676 KB
testcase_24 AC 36 ms
6,676 KB
testcase_25 AC 1,759 ms
348,396 KB
testcase_26 AC 1,120 ms
242,224 KB
testcase_27 AC 1,410 ms
307,992 KB
testcase_28 AC 271 ms
56,292 KB
testcase_29 AC 1,783 ms
364,512 KB
testcase_30 AC 1,176 ms
241,368 KB
testcase_31 AC 914 ms
202,416 KB
testcase_32 AC 39 ms
6,676 KB
testcase_33 AC 244 ms
62,408 KB
testcase_34 AC 517 ms
129,192 KB
testcase_35 AC 1,030 ms
215,908 KB
testcase_36 AC 250 ms
61,668 KB
testcase_37 AC 664 ms
172,180 KB
testcase_38 AC 223 ms
41,088 KB
testcase_39 AC 1,135 ms
236,828 KB
testcase_40 AC 541 ms
111,316 KB
testcase_41 AC 1,001 ms
205,996 KB
testcase_42 AC 129 ms
26,368 KB
testcase_43 AC 119 ms
22,400 KB
testcase_44 AC 378 ms
80,092 KB
testcase_45 AC 1,898 ms
438,704 KB
testcase_46 MLE -
testcase_47 MLE -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
権限があれば一括ダウンロードができます

ソースコード

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;

vector<int> G[24002400];

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);
  };
  auto g=[&](int i,int j,int l){
    return l*h*w+i*w+j;
  };
  
  for(int l=0;l<t-1;l++){
    rep(i,h) rep(j,w){
      if(f(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) G[g(i,j,l)].push_back(g(ni,nj,l+1));
      }
    }
  }
  vector<int> vis(h*w*t);
  auto dfs=[&](auto dfs,int v,int p)->void{
    vis[v]=1;
    for(auto nv:G[v]){
      if(nv==p) continue;
      if(vis[nv]) continue;
      dfs(dfs,nv,v);
    }
  };
  dfs(dfs,g(sy,sx,0),-1);
  rep(l,t){
    if(vis[g(gy,gx,l)]){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;

  return 0;
}
0