結果
問題 | No.323 yuki国 |
ユーザー |
![]() |
提出日時 | 2019-04-12 16:56:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 177 ms / 5,000 ms |
コード長 | 1,408 bytes |
コンパイル時間 | 1,696 ms |
コンパイル使用メモリ | 172,884 KB |
実行使用メモリ | 9,984 KB |
最終ジャッジ日時 | 2024-09-14 06:43:01 |
合計ジャッジ時間 | 5,077 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 32 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef pair<pair<int, int>, int> P;const int L = 55;char C[L][L];bool ok[L][L][2510]; // x, y, snowint dx[4] = {-1, 1, 0, 0};int dy[4] = {0, 0, -1, 1};int h, w, a, b;int sx, sy, gx, gy;int main(){cin.tie(nullptr);ios::sync_with_stdio(false);cin >> h >> w;cin >> a >> sx >> sy;cin >> b >> gx >> gy;ok[sx][sy][a] = true;for(int i = 0; i < h; i++){for(int j = 0; j < w; j++){cin >> C[i][j];}}bool f = false;queue<P> q;q.push({{sx, sy}, a});while(!q.empty()){P p = q.front();q.pop();int x = p.first.first;int y = p.first.second;int snow = p.second;// cout << x << ' ' << y << ' ' << snow << endl;for(int i = 0; i < 4; i++){int nx, ny;nx = dx[i] + x;ny = dy[i] + y;if(nx < 0 or ny < 0 or nx >= h or ny >= w){continue;}int m = (C[nx][ny] == '*' ? 1 : -1) + snow;if(m <= 0 or m >= 2510) continue;if(ok[nx][ny][m]) continue;ok[nx][ny][m] = true;if(nx == gx and ny == gy and m == b){break;}q.push({{nx, ny}, m});}}cout << (ok[gx][gy][b] ? "Yes" : "No") << endl;return 0;}