結果
問題 | No.323 yuki国 |
ユーザー |
![]() |
提出日時 | 2016-08-09 11:48:56 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 152 ms / 5,000 ms |
コード長 | 1,307 bytes |
コンパイル時間 | 571 ms |
コンパイル使用メモリ | 67,108 KB |
実行使用メモリ | 8,576 KB |
最終ジャッジ日時 | 2024-06-28 12:37:38 |
合計ジャッジ時間 | 3,292 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 32 |
ソースコード
#include <iostream>#include <algorithm>#include <vector>#include <cstdio>#include <queue>using namespace std;#define rep(i,n) for(int i=0;i<(n);i++)int dx[4] = {1, 0, 0, -1};int dy[4] = {0, 1, -1, 0};int h, w;int a, si, sj;int b, gi, gj;string s[51];bool board[2010][51][51];struct t{int size, y, x;t(int size, int y, int x) : size(size), y(y), x(x) {}};int main(void){cin >> h >> w;cin >> a >> si >> sj;cin >> b >> gi >> gj;rep(i, h) cin >> s[i];queue<t> q;q.push(t(a, si, sj));board[a][si][sj] = true;while(!q.empty()){t now = q.front(); q.pop();for (int i = 0; i < 4; ++i){if(0 <= now.y + dy[i] && now.y + dy[i] < h &&0 <= now.x + dx[i] && now.x + dx[i] < w){if(s[now.y + dy[i]][now.x + dx[i]] == '*'){if(now.size <= 2000 && board[now.size + 1][now.y + dy[i]][now.x + dx[i]] == false){board[now.size + 1][now.y + dy[i]][now.x + dx[i]] = true;q.push(t(now.size + 1, now.y + dy[i], now.x + dx[i]));}}else{if(2 <= now.size && board[now.size - 1][now.y + dy[i]][now.x + dx[i]] == false){board[now.size - 1][now.y + dy[i]][now.x + dx[i]] = true;q.push(t(now.size - 1, now.y + dy[i], now.x + dx[i]));}}}}}if(board[b][gi][gj]) printf("Yes\n");else printf("No\n");return 0;}