結果
問題 | No.323 yuki国 |
ユーザー |
|
提出日時 | 2016-12-13 12:09:17 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 263 ms / 5,000 ms |
コード長 | 1,710 bytes |
コンパイル時間 | 1,720 ms |
コンパイル使用メモリ | 177,544 KB |
実行使用メモリ | 12,160 KB |
最終ジャッジ日時 | 2024-06-28 12:40:12 |
合計ジャッジ時間 | 6,570 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 32 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long ll;typedef vector< int > vi;typedef vector< vi > vvi;typedef vector< ll > vl;typedef vector< vl > vvl;typedef pair< int, int > pii;typedef vector< pii > vp;typedef vector< double > vd;typedef vector< vd > vvd;typedef vector< string > vs;template< class T1, class T2 >int upmin( T1 &x, T2 v ){if( x > v ){x = v;return 1;}return 0;}template< class T1, class T2 >int upmax( T1 &x, T2 v ){if( x < v ){x = v;return 1;}return 0;}const int INF = 0x3f3f3f3f;int H, W;int A, Sx, Sy;int B, Gx, Gy;vs G;void init(){cin >> H >> W;cin >> A >> Sx >> Sy;cin >> B >> Gx >> Gy;G = vs( H );for( int i = 0; i < H; ++i )cin >> G[ i ];}const int MAXHP = 1000 + 2500;bool dp[ 50 + 1 ][ 50 + 1 ][ MAXHP + 1 ];void preprocess(){dp[ Sx ][ Sy ][ A ] = 1;queue< tuple< int, int, int > > que;que.emplace( Sx, Sy, A );while( not que.empty() ){int x, y, v; tie( x, y, v ) = que.front(); que.pop();const int dx[] = { 0, 1, 0, -1 };const int dy[] = { 1, 0, -1, 0 };for( int di = 0; di < 4; ++di ){int nx = x + dx[ di ];int ny = y + dy[ di ];if( not ( 0 <= nx and nx < H and 0 <= ny and ny < W ) ) continue;int nv = v + ( G[ nx ][ ny ] == '*' ? 1 : -1 );if( not ( 0 < nv and nv <= MAXHP ) ) continue;if( dp[ nx ][ ny ][ nv ] ) continue;dp[ nx ][ ny ][ nv ] = 1;que.emplace( nx, ny, nv );}}}void solve(){const string msg[] = { "No", "Yes" };cout << msg[ dp[ Gx ][ Gy ][ B ] ] << endl;}signed main(){ios::sync_with_stdio( 0 );init();preprocess();solve();return 0;}