結果
問題 | No.323 yuki国 |
ユーザー |
![]() |
提出日時 | 2020-01-17 14:28:50 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 335 ms / 5,000 ms |
コード長 | 992 bytes |
コンパイル時間 | 1,737 ms |
コンパイル使用メモリ | 175,376 KB |
実行使用メモリ | 38,868 KB |
最終ジャッジ日時 | 2024-06-25 15:50:52 |
合計ジャッジ時間 | 7,869 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 32 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define rep(i,n) for(int i = 0; i < (n);i++)#define sz(x) int(x.size())typedef long long ll;typedef pair<int,int> P;int ok[51][51][3601];int dx[] = {1, 0, -1, 0};int dy[] = {0, 1, 0, -1};int main(){int h, w, a, b;int sx, sy, gx, gy;cin >> h >> w;cin >> a >> sx >> sy;cin >> b >> gx >> gy;vector<string> s(h);rep(i,h) cin >> s[i];ok[sx][sy][a] = 1;queue<P> que;que.push(make_pair(sx*100+sy, a));while (!que.empty()) {auto p = que.front(); que.pop();rep(i, 4) {int x = p.first / 100 + dx[i];int y = p.first % 100 + dy[i];if (x < 0 || y < 0 || x >= h || y >= w) continue;int cost = p.second + (s[x][y] == '*' ? 1 : -1);if (cost <= 0 || cost > 3500) continue;if (ok[x][y][cost]) continue;ok[x][y][cost] = 1;que.push(make_pair(x*100+y, cost));}}if (ok[gx][gy][b]) cout << "Yes" << endl;else cout << "No" << endl;return 0;}