結果

問題 No.323 yuki国
ユーザー latte0119
提出日時 2016-05-24 18:45:14
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 112 ms / 5,000 ms
コード長 1,488 bytes
コンパイル時間 701 ms
コンパイル使用メモリ 79,236 KB
実行使用メモリ 8,448 KB
最終ジャッジ日時 2024-06-28 12:32:41
合計ジャッジ時間 3,200 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<cstdio>
#include<algorithm>
#include<vector>
#include<iostream>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
#include<map>
#include<set>
#include<sstream>
#include<bitset>
#include<numeric>
#include<climits>
using namespace std;
typedef long long ll;
template<typename A,typename B>inline void chmin(A &a, B b) { if (a > b)a = b; }
template<typename A,typename B>inline void chmax(A &a, B b) { if (a < b)a = b; }
int H, W;
int A, sy, sx;
int B, gy, gx;
int fld[50][50];
const int dx[] = { -1,0,1,0 };
const int dy[] = { 0,-1,0,1 };
const int lim = 2000;
bool vis[50][50][lim];
int main() {
cin >> H >> W;
cin >> A >> sy >> sx;
cin >> B >> gy >> gx;
A--; B--;
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
char c;
cin >> c;
fld[i][j] = c == '*' ? 1 : -1;
}
}
queue<tuple<int, int, int>>que;
que.push(make_tuple(sy, sx, A));
vis[sy][sx][A] = true;
while (que.size()) {
int y, x, s;
tie(y, x, s) = que.front();
que.pop();
for (int i = 0; i < 4; i++) {
int ny = y + dy[i], nx = x + dx[i];
if (ny < 0 || ny >= H)continue;
if(nx < 0 || nx >= W)continue;
if (s + fld[ny][nx] < 0 || s + fld[ny][nx] >= lim)continue;
if (vis[ny][nx][s + fld[ny][nx]])continue;
vis[ny][nx][s + fld[ny][nx]] = true;
que.push(make_tuple(ny, nx, s + fld[ny][nx]));
}
}
if (vis[gy][gx][B])cout << "Yes" << endl;
else cout << "No" << endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0