結果
問題 |
No.323 yuki国
|
ユーザー |
![]() |
提出日時 | 2016-06-10 00:32:19 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,391 bytes |
コンパイル時間 | 643 ms |
コンパイル使用メモリ | 74,112 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-09 09:15:29 |
合計ジャッジ時間 | 4,407 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 21 WA * 1 RE * 10 |
ソースコード
#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 <= b + h * w && !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; }