結果
問題 |
No.323 yuki国
|
ユーザー |
![]() |
提出日時 | 2015-12-16 00:45:19 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 2,048 bytes |
コンパイル時間 | 1,110 ms |
コンパイル使用メモリ | 111,212 KB |
実行使用メモリ | 815,872 KB |
最終ジャッジ日時 | 2024-09-16 05:25:36 |
合計ジャッジ時間 | 22,311 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 9 MLE * 7 -- * 16 |
ソースコード
#include <iostream> #include <algorithm> #include <cmath> #include <vector> #include <complex> #include <queue> #include <deque> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <iomanip> #include <assert.h> #include <array> #include <cstdio> #include <cstring> #include <random> #include <functional> #include <numeric> #include <bitset> using namespace std; #define REP(i,a,b) for(int i=a;i<(int)b;i++) #define rep(i,n) REP(i,0,n) #define all(c) (c).begin(), (c).end() #define zero(a) memset(a, 0, sizeof a) #define minus(a) memset(a, -1, sizeof a) #define minimize(a, x) a = std::min(a, x) #define maximize(a, x) a = std::max(a, x) typedef long long ll; int const inf = 1<<29; int dx[4] = {-1,0,1,0}; int dy[4] = {0,-1,0,1}; template<class T> constexpr bool in_range(T y, T x, T H, T W) { return 0<=y&&y<H&&0<=x&&x<W; } unordered_set<int> G[2002][50][50]; unordered_set<int> vis[50][50]; //set<int> G[2002][50][50]; int main() { int H, W; cin >> H >> W; int A, si, sj; cin >> A >> si >> sj; int B, gi, gj; cin >> B >> gi >> gj; vector<string> yuki(H); rep(i, H) { cin >> yuki[i]; } G[0][si][sj].insert(A); vis[si][sj].insert(A); rep(k, 2001) { // rep(i, H) rep(j, W) G[(k+1)&1][i][j].clear(); rep(i, H) rep(j, W) { if(i == gi && j == gj && G[k][i][j].count(B)) { cout << "Yes" << endl; exit(0); } for(auto const& e: G[k][i][j]) { if(e - 1 < 0) { continue; } rep(d, 4) { auto const ni = i + dy[d], nj = j + dx[d]; if(!in_range(ni, nj, H, W)) { continue; } int const nc = e + (yuki[ni][nj] == '*' ? 1 : -1); if(vis[ni][nj].count(nc)) { continue; } vis[ni][nj].insert(nc); G[k+1][ni][nj].insert(nc); } } } /* rep(i, H) { rep(j, W) { cout << (G[k][i][j].empty() ? 0 : *G[k][i][j].begin()) << " "; } cout << endl; } cout << "\n-------------------\n"; */ } cout << "No" << endl; return 0; }