結果
問題 | No.323 yuki国 |
ユーザー |
|
提出日時 | 2023-03-10 15:52:21 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 126 ms / 5,000 ms |
コード長 | 1,002 bytes |
コンパイル時間 | 1,869 ms |
コンパイル使用メモリ | 184,320 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-18 03:19:48 |
合計ジャッジ時間 | 4,341 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 32 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main(){ios::sync_with_stdio(false);cin.tie(0);int h, w, a, sy, sx, b, gy, gx;cin >> h >> w >> a >> sy >> sx >> b >> gy >> gx;vector<vector<vector<bool>>> dp(h, vector<vector<bool>>(w, vector<bool>(2001)));vector<string> A(h);for(auto &&s : A) cin >> s;queue<tuple<int,int,int>> nxt;dp[sy][sx][a] = true;nxt.emplace(sy, sx, a);int y, x, v;while(!nxt.empty()){tie(y, x, v) = nxt.front();nxt.pop();for(int i = 0; i < 4; i++){int ny = y + (i == 0) - (i == 1);int nx = x + (i == 2) - (i == 3);if(ny < 0 || nx < 0 || ny >= h || nx >= w) continue;int nv = v + (A[ny][nx] == '*' ? 1 : -1);if(nv <= 0 || nv >= 2001) continue;if(dp[ny][nx][nv]) continue;dp[ny][nx][nv] = true;nxt.emplace(ny, nx, nv);}}cout << (dp[gy][gx][b] ? "Yes" : "No") << '\n';}