結果

問題 No.323 yuki国
ユーザー kimiyuki
提出日時 2016-04-19 18:15:40
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 900 ms / 5,000 ms
コード長 1,240 bytes
コンパイル時間 1,140 ms
コンパイル使用メモリ 89,556 KB
実行使用メモリ 38,896 KB
最終ジャッジ日時 2024-06-28 12:32:19
合計ジャッジ時間 13,967 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

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

#include <iostream>
#include <vector>
#include <queue>
#include <tuple>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
using namespace std;
const int lim = 10000;
const int dy[4] = { -1, 1, 0, 0 };
const int dx[4] = { 0, 0, 1, -1 };
int main() {
int h, w; cin >> h >> w;
int a, sy, sx; cin >> a >> sy >> sx;
int b, gy, gx; cin >> b >> gy >> gx;
vector<string> m(h); repeat (y,h) cin >> m[y];
vector<vector<vector<bool> > > used(lim, vector<vector<bool> >(h, vector<bool>(w)));
queue<tuple<int,int,int> > que;
que.push(make_tuple(a, sy, sx));
used[a][sy][sx] = true;
while (not que.empty()) {
int c, y, x; tie(c, y, x) = que.front(); que.pop();
repeat (i,4) {
int ny = y + dy[i];
int nx = x + dx[i];
if (0 <= ny and ny < h and 0 <= nx and nx < w) {
int nc = c + (m[ny][nx] == '*' ? 1 : -1);
if (1 <= nc and nc < lim) {
if (not used[nc][ny][nx]) {
used[nc][ny][nx] = true;
que.push(make_tuple(nc, ny, nx));
}
}
}
}
}
cout << (used[b][gy][gx] ? "Yes" : "No") << endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0