結果
問題 | No.323 yuki国 |
ユーザー |
![]() |
提出日時 | 2015-12-16 00:09:27 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 340 ms / 5,000 ms |
コード長 | 1,355 bytes |
コンパイル時間 | 1,466 ms |
コンパイル使用メモリ | 164,220 KB |
実行使用メモリ | 38,892 KB |
最終ジャッジ日時 | 2024-06-28 12:16:08 |
合計ジャッジ時間 | 7,206 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 32 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) //------------------------------------------------------- int H,W; int A,SY,SX; int B,GY,GX; string M[51]; int ok[51][51][3600]; void solve() { int i,j,k,l,r,x,y; string s; cin>>H>>W; cin>>A>>SY>>SX; cin>>B>>GY>>GX; FOR(y,H) cin>>M[y]; ok[SY][SX][A]=1; queue<int> Q; Q.push(A*10000+SY*100+SX); while(Q.size()) { int r=Q.front(); Q.pop(); int sz=r/10000; int cy=r/100%100; int cx=r%100; FOR(i,4) { int dd[]={0,1,0,-1}; int ty=cy+dd[i]; int tx=cx+dd[i^1]; if(ty<0 || ty>=H || tx<0 || tx>=W) continue; int nz=sz+((M[ty][tx]=='*')?1:-1); if(nz<=0 || nz>3500) continue; if(ok[ty][tx][nz]) continue; ok[ty][tx][nz]=1; Q.push(nz*10000+ty*100+tx); } } if(ok[GY][GX][B]) _P("Yes\n"); else _P("No\n"); } int main(int argc,char** argv){ string s;int i; if(argc==1) ios::sync_with_stdio(false); FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin); solve(); return 0; }