結果
問題 | No.323 yuki国 |
ユーザー |
|
提出日時 | 2015-12-19 21:36:35 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 235 ms / 5,000 ms |
コード長 | 1,530 bytes |
コンパイル時間 | 1,300 ms |
コンパイル使用メモリ | 105,076 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-28 12:27:26 |
合計ジャッジ時間 | 5,488 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 32 |
ソースコード
#include <cstdio> #include <iostream> #include <sstream> #include <fstream> #include <iomanip> #include <algorithm> #include <cmath> #include <string> #include <vector> #include <list> #include <queue> #include <stack> #include <set> #include <map> #include <bitset> #include <numeric> #include <limits> #include <climits> #include <cfloat> #include <functional> using namespace std; const int dy[] = {-1, 0, 1, 0}; const int dx[] = {0, 1, 0, -1}; int main() { int h, w; int a, sy, sx; int b, gy, gx; cin >> h >> w >> a >> sy >> sx >> b >> gy >> gx; vector<string> grid(h); for(int i=0; i<h; ++i) cin >> grid[i]; vector<vector<bitset<3000> > > dp(h, vector<bitset<3000> >(w)); dp[sy][sx][a] = true; queue<tuple<int, int, int> > q; q.push(make_tuple(sy, sx, a)); while(!q.empty()){ int y, x, size; tie(y, x, size) = q.front(); q.pop(); for(int i=0; i<4; ++i){ int y2 = y + dy[i]; int x2 = x + dx[i]; if(!(0 <= y2 && y2 < h && 0 <= x2 && x2 < w)) continue; int size2 = size; if(grid[y2][x2] == '*') ++ size2; else -- size2; if(0 < size2 && size2 < 3000 && !dp[y2][x2][size2]){ dp[y2][x2][size2] = true; q.push(make_tuple(y2, x2, size2)); } } } if(dp[gy][gx][b]) cout << "Yes" << endl; else cout << "No" << endl; return 0; }