結果
| 問題 |
No.402 最も海から遠い場所
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-11-27 22:31:42 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 998 bytes |
| コンパイル時間 | 1,765 ms |
| コンパイル使用メモリ | 180,556 KB |
| 実行使用メモリ | 158,660 KB |
| 最終ジャッジ日時 | 2024-11-27 12:22:23 |
| 合計ジャッジ時間 | 4,979 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 4 WA * 15 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };
int in_range( int h, int w, int x, int y ){
return 0 <= x and x < h and 0 <= y and y < w;
}
signed main(){
int H, W; cin >> H >> W;
vector< string > G( H );
for( int i = 0; i < H; ++i )
cin >> G[ i ];
queue< tuple< int, int, int > > que;
vector< vector< int > > vis( H, vector< int >( W ) );
for( int i = 0; i < H; ++i )
for( int j = 0; j < W; ++j )
if( G[ i ][ j ] == '.' )
que.emplace( 0, i, j ),
vis[ i ][ j ] = 1;
int ans = 0;
while( not que.empty() ){
int d, x, y; tie( d, x, y ) = que.front(); que.pop();
ans = max( ans, d );
for( int di = 0; di < 4; ++di ){
int nx = x + dx[ di ];
int ny = y + dy[ di ];
if( not in_range( H, W, nx, ny ) ) continue;
if( vis[ nx ][ ny ] ) continue;
vis[ nx ][ ny ] = 1;
que.emplace( d + 1, nx, ny );
}
}
cout << ans << endl;
return 0;
}