結果
問題 | No.323 yuki国 |
ユーザー |
![]() |
提出日時 | 2016-06-10 00:35:05 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 80 ms / 5,000 ms |
コード長 | 1,387 bytes |
コンパイル時間 | 688 ms |
コンパイル使用メモリ | 73,804 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-28 12:34:37 |
合計ジャッジ時間 | 2,785 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 32 |
ソースコード
#include <iostream> #include <vector> #include <map> #include <queue> #include <algorithm> using namespace std; #define REP(i,s,e) for (i = s; i <= e; i++) #define rep(i,n) REP (i,0,(int)(n)-1) #define RREP(i,s,e) for (i = s; i >= e; i--) #define rrep(i,n) RREP (i,(int)(n)-1,0) #define INF (int)1e8 #define MOD (int)(1e9+7) typedef long long ll; bool arrive[50][50][1251]; int dxy[4] = {-1,0,1,0}; int main(void) { int i, j, h, w, a, b, si, sj, gi, gj; string m[50]; cin >> h >> w; cin >> a >> si >> sj; cin >> b >> gi >> gj; rep (i,h) cin >> m[i]; queue<pair<pair<int,int>,int>> q; arrive[si][sj][a] = true; q.push(make_pair(make_pair(si,sj),a)); while (!q.empty()) { int x = q.front().first.first; int y = q.front().first.second; int size = q.front().second; q.pop(); rep (i,4) { int nx = x + dxy[i]; int ny = y + dxy[(i+1)%4]; if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue; int nsize = size + (m[nx][ny] == '*' ? 1 : -1); if (nsize > 0 && nsize <= 1250 && !arrive[nx][ny][nsize]) { arrive[nx][ny][nsize] = true; q.push(make_pair(make_pair(nx,ny),nsize)); } } } if (arrive[gi][gj][b]) cout << "Yes" << endl; else cout << "No" << endl; return 0; }