結果

問題 No.323 yuki国
ユーザー tjaketjake
提出日時 2015-12-16 01:21:45
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 176 ms / 5,000 ms
コード長 2,186 bytes
コンパイル時間 614 ms
コンパイル使用メモリ 79,572 KB
実行使用メモリ 25,300 KB
最終ジャッジ日時 2023-09-10 21:16:46
合計ジャッジ時間 3,891 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 102 ms
24,800 KB
testcase_09 AC 106 ms
24,768 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 103 ms
24,876 KB
testcase_14 AC 97 ms
24,944 KB
testcase_15 AC 95 ms
23,112 KB
testcase_16 AC 102 ms
24,940 KB
testcase_17 AC 112 ms
25,012 KB
testcase_18 AC 8 ms
8,236 KB
testcase_19 AC 63 ms
16,608 KB
testcase_20 AC 70 ms
20,044 KB
testcase_21 AC 119 ms
24,512 KB
testcase_22 AC 176 ms
25,200 KB
testcase_23 AC 125 ms
25,300 KB
testcase_24 AC 98 ms
23,068 KB
testcase_25 AC 98 ms
23,000 KB
testcase_26 AC 32 ms
15,648 KB
testcase_27 AC 30 ms
15,560 KB
testcase_28 AC 107 ms
24,948 KB
testcase_29 AC 105 ms
24,948 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<cmath>
using namespace std;

#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define absd(x) (x<0?-(x):x)
#define pow2(x) ((x)*(x))
#define rep(i,n) for(int i=0; i<n; ++i)
#define repr(i,n) for(int i=n-1; i>=0; --i)
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define replr(i,s,n) for(int i=n; i>=s; --i)
#define repf(i,s,n,j) for(int i=s; i<=n; i+=j)
#define repe(e,obj) for(auto e : obj)

#define SP << " " <<
#define COL << " : " <<
#define COM << ", " <<
#define ARR << " -> " <<
#define PNT(STR) cout << STR << endl
#define POS(X,Y) "(" << X << ", " << Y << ")"
#define DEB(A) " (" << #A << ") " << A
#define DEBREP(i,n,val) for(int i=0; i<n; ++i) cout << val << " "; cout << endl
#define ALL(V) (V).begin(), (V).end()
#define INF 1000000007
#define INFLL 10000000000000000007LL
#define EPS 1e-9

typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
typedef pair<P, int> PI;
typedef pair<int, P> IP;
typedef pair<P, P> PP;
typedef priority_queue<P, vector<P>, greater<P> > pvqueue;

#define W 53
#define N 2203

int h, w;
int a, si, sj, b, gi, gj;
int used[W][W][N];
char m[W][W];

int dx[] = {-1,0,1,0};
int dy[] = {0,-1,0,1};

int main() {
  cin >> h >> w;
  cin >> a >> si >> sj >> b >> gi >> gj;
  rep(i, h) cin >> m[i];

  queue<PI> que;
  que.push(PI(P(sj, si), a));
  used[si][sj][a] = true;
  while(!que.empty()) {
    PI p = que.front(); que.pop();
    int x = p.first.first, y = p.first.second, sz = p.second;
    rep(k, 4) {
      int nx = x + dx[k], ny = y + dy[k];
      if(nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
      int n_sz = (m[ny][nx]=='*' ? sz+1 : sz-1);
      if(n_sz > (2*(h+w)+a+b+1)) n_sz = (2*(h+w)+a+b);
      if(n_sz>0 && !used[ny][nx][n_sz]) {
        que.push(PI(P(nx, ny), n_sz));
        used[ny][nx][n_sz] = true;
      }
    }
  }
  cout << (used[gi][gj][b] ? "Yes" : "No") << endl;

  return 0;
}
0