結果
問題 |
No.323 yuki国
|
ユーザー |
|
提出日時 | 2016-04-19 19:40:59 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 60 ms / 5,000 ms |
コード長 | 2,277 bytes |
コンパイル時間 | 849 ms |
コンパイル使用メモリ | 91,636 KB |
実行使用メモリ | 6,272 KB |
最終ジャッジ日時 | 2024-06-28 12:30:46 |
合計ジャッジ時間 | 2,451 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 32 |
ソースコード
#include <iostream> #include <queue> #include <map> #include <list> #include <vector> #include <string> #include <limits> #include <cassert> #include <fstream> #include <cstring> #include <bitset> #include <iomanip> #include <algorithm> #include <functional> #include <cstdio> #include <ciso646> using namespace std; #define FOR(i,a,b) for (int i=(a);i<(b);i++) #define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--) #define REP(i,n) for (int i=0;i<(n);i++) #define RREP(i,n) for (int i=(n)-1;i>=0;i--) #define inf 0x3f3f3f3f3f3f3f3f #define mp make_pair #define all(a) (a).begin(),(a).end() #define pii pair<long long,long long> #define pcc pair<char,char> #define pic pair<int,char> #define pci pair<char,int> #define VS vector<string> #define VI vector<int> #define DEBUG(x) cout<<#x<<": "<<x<<endl #define pi 2*acos(0.0) #define INFILE() freopen("in.txt","r",stdin) #define OUTFILE() freopen("out.txt","w",stdout) #define ll long long #define ull unsigned long long #define eps 1e-14 // l = list(map(int, input().split())) // l = ts = [input() for i in range(n)] int dx[] = { 1,0,-1,0 }; int dy[] = { 0,1,0,-1 }; struct point { int x, y; point(int x_, int y_):x(x_), y(y_){} point(){} }; bool operator < (const point& left, const point& right) { return left.y < right.y; } bool used[2000][51][51] = {}; int main(void) { int H, W; cin >> H >> W; int A; cin >> A; point S; cin >> S.y >> S.x; int B; cin >> B; point G; cin >> G.y >> G.x; vector<string> M(H); for (auto &a : M) cin >> a; int cut = max(A, B) + H + W;//これ以上行くパターンはウロウロしてるのでいらない queue<pair<int, point>> que; que.push(mp(A, point(S))); used[A][S.y][S.x] = true; while (not que.empty()) { auto t = que.front(); que.pop(); int x = t.second.x; int y = t.second.y; if (used[B][G.y][G.x]) break; REP(i, 4) { if (0 <= x + dx[i] and x + dx[i] < W and 0 <= y + dy[i] and y + dy[i] < H) { int score = t.first + (M[y + dy[i]][x + dx[i]] == '.' ? -1 : 1); if (not used[score][y + dy[i]][x + dx[i]]) { used[score][y + dy[i]][x + dx[i]] = true; if (score <= 0 or score > cut) continue; que.push(mp(score, point(x + dx[i], y + dy[i]))); } } } } cout << (used[B][G.y][G.x] ? "Yes" : "No") << endl;; return 0; }