結果

問題 No.323 yuki国
ユーザー puru
提出日時 2016-07-04 20:08:01
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 363 ms / 5,000 ms
コード長 4,541 bytes
コンパイル時間 1,618 ms
コンパイル使用メモリ 128,780 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-28 12:37:24
合計ジャッジ時間 4,904 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

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

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back
#define debug(fmt, ...) \
fprintf( stderr, \
fmt "\n", \
##__VA_ARGS__ \
)
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 29;
const double EPS = 1e-10;
double zero(double d) {
return d < EPS ? 0.0 : d;
}
template<class T>
bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template<class T>
bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return true;
}
return false;
}
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
return os << '(' << p.first << ',' << p.second << ')';
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &a) {
os << '[';
rep(i, a.size()) os << (i ? " " : "") << a[i];
return os << ']';
}
string toString(int i) {
stringstream ss;
ss << i;
return ss.str();
}
const int MOD = 1000000007;
// a^k
ll fpow(ll a, ll k, int M) {
ll res = 1ll;
ll x = a;
while (k != 0) {
if ((k & 1) == 1)
res = (res * x) % M;
x = (x * x) % M;
k >>= 1;
}
return res;
}
struct prepare {
prepare() {
cout.setf(ios::fixed, ios::floatfield);
cout.precision(8);
ios_base::sync_with_stdio(false);
}
} _prepare;
int dr[] = {1, 0, -1, 0};
int dc[] = {0, -1, 0, 1};
const int MAX_SIZE = 1000 + 50 + 50 + 2000;
vector<vector<bool> > memo(MAX_SIZE + 10, vector<bool>(50*50 + 50 + 1, false));
int main() {
int H, W;
int A, Sr, Sc;
int B, Gr, Gc;
cin >> H >> W >> A >> Sr >> Sc >> B >> Gr >> Gc;
vector<string> field(H);
rep(i, H)
cin >> field[i];
queue<pii> que;
que.push(mp(Sr * W + Sc, A));
while (!que.empty()) {
int _pos = que.front().first;
int now_r = _pos / W;
int now_c = _pos % W;
int size = que.front().second;
que.pop();
if (memo[size][_pos])
continue;
if (size == 0)
continue;
if (now_r == Gr && now_c == Gc && size == B) {
cout << "Yes" << endl;
return 0;
}
if (size >= MAX_SIZE) {
cout << "No" << endl;
return 0;
}
memo[size][_pos] = true;
rep(i, 4) {
int next_r = now_r + dr[i];
int next_c = now_c + dc[i];
if (0 <= next_r && next_r < H &&
0 <= next_c && next_c < W) {
int npos = next_r * W + next_c;
if (field[next_r][next_c] == '.') {
if(!memo[size][npos])
que.push(mp(npos, size - 1));
}
else {
if(!memo[size][npos])
que.push(mp(npos, size + 1));
}
}
}
}
cout << "No" << endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0