結果
| 問題 | No.323 yuki国 |
| コンテスト | |
| ユーザー |
SSRS
|
| 提出日時 | 2020-11-11 23:29:50 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 122 ms / 5,000 ms |
| コード長 | 1,149 bytes |
| コンパイル時間 | 2,189 ms |
| コンパイル使用メモリ | 183,888 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-22 18:54:38 |
| 合計ジャッジ時間 | 5,266 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 32 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
vector<int> dy = {1, 0, -1, 0};
vector<int> dx = {0, 1, 0, -1};
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> M(H);
for (int i = 0; i < H; i++){
cin >> M[i];
}
vector<vector<vector<bool>>> used(H, vector<vector<bool>>(W, vector<bool>(1200, false)));
used[Si][Sj][A] = true;
queue<tuple<int, int, int>> Q;
Q.push(make_tuple(Si, Sj, A));
while (!Q.empty()){
int y = get<0>(Q.front());
int x = get<1>(Q.front());
int s = get<2>(Q.front());
Q.pop();
for (int i = 0; i < 4; i++){
int y2 = y + dy[i];
int x2 = x + dx[i];
if (0 <= y2 && y2 < H && 0 <= x2 && x2 < W){
int s2 = s;
if (M[y2][x2] == '*'){
s2++;
} else {
s2--;
}
if (1 <= s2 && s2 < 1200){
if (!used[y2][x2][s2]){
used[y2][x2][s2] = true;
Q.push(make_tuple(y2, x2, s2));
}
}
}
}
}
if (used[Gi][Gj][B]){
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
SSRS