結果
問題 | No.323 yuki国 |
ユーザー | tubo28 |
提出日時 | 2015-12-16 01:28:53 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 214 ms / 5,000 ms |
コード長 | 2,699 bytes |
コンパイル時間 | 1,467 ms |
コンパイル使用メモリ | 168,304 KB |
実行使用メモリ | 27,136 KB |
最終ジャッジ日時 | 2024-06-28 12:21:36 |
合計ジャッジ時間 | 4,976 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 9 ms
27,008 KB |
testcase_01 | AC | 8 ms
27,008 KB |
testcase_02 | AC | 9 ms
27,008 KB |
testcase_03 | AC | 9 ms
27,100 KB |
testcase_04 | AC | 9 ms
26,952 KB |
testcase_05 | AC | 9 ms
27,008 KB |
testcase_06 | AC | 8 ms
27,008 KB |
testcase_07 | AC | 10 ms
27,136 KB |
testcase_08 | AC | 135 ms
26,880 KB |
testcase_09 | AC | 75 ms
26,880 KB |
testcase_10 | AC | 8 ms
27,008 KB |
testcase_11 | AC | 9 ms
27,008 KB |
testcase_12 | AC | 9 ms
27,044 KB |
testcase_13 | AC | 75 ms
26,976 KB |
testcase_14 | AC | 140 ms
27,008 KB |
testcase_15 | AC | 80 ms
27,136 KB |
testcase_16 | AC | 159 ms
27,136 KB |
testcase_17 | AC | 89 ms
27,008 KB |
testcase_18 | AC | 10 ms
27,008 KB |
testcase_19 | AC | 113 ms
27,008 KB |
testcase_20 | AC | 13 ms
27,028 KB |
testcase_21 | AC | 214 ms
27,136 KB |
testcase_22 | AC | 36 ms
27,008 KB |
testcase_23 | AC | 210 ms
27,136 KB |
testcase_24 | AC | 16 ms
27,136 KB |
testcase_25 | AC | 99 ms
27,008 KB |
testcase_26 | AC | 17 ms
26,880 KB |
testcase_27 | AC | 193 ms
27,136 KB |
testcase_28 | AC | 89 ms
27,136 KB |
testcase_29 | AC | 87 ms
27,136 KB |
testcase_30 | AC | 9 ms
27,008 KB |
testcase_31 | AC | 10 ms
27,008 KB |
testcase_32 | AC | 9 ms
27,008 KB |
testcase_33 | AC | 8 ms
27,008 KB |
testcase_34 | AC | 10 ms
27,120 KB |
testcase_35 | AC | 9 ms
27,008 KB |
testcase_36 | AC | 8 ms
26,844 KB |
testcase_37 | AC | 8 ms
26,988 KB |
ソースコード
#define _CRT_SECURE_NO_WARNINGS // #define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; template<class T> ostream &operator << (ostream &os, const vector<T> &); template<size_t n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, const tuple<T...> &){} template<size_t n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream &os, const tuple<T...> &t){ os << (n == 0 ? "" : " ") << get<n>(t); _ot<n+1>(os, t); } template<class...T> ostream &operator << (ostream &os, const tuple<T...> &t){ _ot<0>(os, t); return os; } template<class T, class U> ostream & operator << (ostream &os, const pair<T,U> &p){ return os << "(" << p.first << ", " << p.second << ") "; } template<class T> ostream &operator << (ostream &os, const vector<T> &v){ for(size_t i = 0; i < v.size(); i++) os << v[i] << (i + 1 == v.size() ? "" : ", "); return os; } #ifdef DEBUG #define dump(...) (cerr << #__VA_ARGS__ << " = " << make_tuple(__VA_ARGS__) \ << " (L : " << __LINE__ << ")" << endl) #else #define dump(...) #endif #define all(c) begin(c), end(c) #define range(i,a,b) for(int i = a; i < (int)(b); i++) #define rep(i,b) range(i,0,b) #define pb push_back #define eb emplace_back #define mp make_pair #define mt make_tuple using ll = long long; // #define int ll using vi = vector<int>; using vvi = vector<vi>; using pii = pair<int,int>; void fastios(){ ios_base::sync_with_stdio(0); cin.tie(0); } int const mod = 1000000007; auto const inf = numeric_limits<int>::max()/8; int h,w; int g[55][55]; int a,si,sj; int b,gi,gj; int memo[55][55][2000]; int solve(){ using State = tuple<int,int,int>; fill((int*)begin(memo), (int*)end(memo), 0); queue<State> q; q.emplace(si,sj,a); while(q.size()){ int ci,cj,cs; tie(ci,cj,cs) = q.front(); q.pop(); if(memo[ci][cj][cs]) continue; memo[ci][cj][cs] = true; if(ci == gi && cj == gj && b == cs) return true; int dir[4][2] = { {0,1}, {1,0}, {0,-1}, {-1,0} }; for(auto d : dir){ int ni = ci + d[0]; int nj = cj + d[1]; if(ni >= h || nj >= w || ni < 0 || nj < 0) continue; int ns = cs + g[ni][nj]; if(memo[ni][nj][ns]) continue; if(ns <= 0 || ns >= 2000) continue; q.emplace(ni, nj, ns); } } return false; } int main(){ while(cin >> h >> w){ cin >> a >> si >> sj; cin >> b >> gi >> gj; rep(i,h){ string s; cin >> s; rep(j,w){ g[i][j] = s[j] == '*' ? 1 : -1; } } puts(solve() ? "Yes" : "No"); } }