結果
問題 | No.323 yuki国 |
ユーザー |
![]() |
提出日時 | 2018-11-14 11:52:55 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 220 ms / 5,000 ms |
コード長 | 1,137 bytes |
コンパイル時間 | 2,349 ms |
コンパイル使用メモリ | 203,940 KB |
最終ジャッジ日時 | 2025-01-06 16:38:12 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 32 |
ソースコード
#include<bits/stdc++.h>using namespace std;using Int = long long;template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}//INSERT ABOVE HEREconst Int MAX = 4050;bool dp[MAX][50][50];signed main(){Int h,w;cin>>h>>w;Int a,sy,sx;cin>>a>>sy>>sx;Int b,gy,gx;cin>>b>>gy>>gx;vector<string> st(h);for(Int i=0;i<h;i++) cin>>st[i];using T = tuple<Int, Int, Int>;queue<T> q;memset(dp,0,sizeof(dp));dp[a][sy][sx]=1;q.emplace(a,sy,sx);auto in=[&](Int y,Int x){return 0<=y&&y<h&&0<=x&&x<w;};auto check=[&](Int s){return 0<s&&s<MAX;};Int dy[]={0,0,1,-1};Int dx[]={1,-1,0,0};while(!q.empty()){Int s,y,x;tie(s,y,x)=q.front();q.pop();for(Int k=0;k<4;k++){Int ny=y+dy[k],nx=x+dx[k];if(!in(ny,nx)) continue;Int ns=s+(st[ny][nx]=='.'?-1:1);if(!check(ns)) continue;if(dp[ns][ny][nx]) continue;dp[ns][ny][nx]=1;q.emplace(ns,ny,nx);}}cout<<(dp[b][gy][gx]?"Yes":"No")<<endl;return 0;}