結果
| 問題 |
No.2646 Cycle Maze
|
| ユーザー |
umezo
|
| 提出日時 | 2024-02-26 03:28:14 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,297 bytes |
| コンパイル時間 | 2,886 ms |
| コンパイル使用メモリ | 255,804 KB |
| 実行使用メモリ | 814,336 KB |
| 最終ジャッジ日時 | 2024-09-29 11:32:42 |
| 合計ジャッジ時間 | 27,534 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 42 MLE * 2 -- * 7 |
ソースコード
#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;
}
umezo