結果
問題 | No.402 最も海から遠い場所 |
ユーザー | uenoku |
提出日時 | 2016-08-31 04:43:43 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 729 ms / 3,000 ms |
コード長 | 1,503 bytes |
コンパイル時間 | 1,072 ms |
コンパイル使用メモリ | 88,924 KB |
実行使用メモリ | 116,264 KB |
最終ジャッジ日時 | 2023-08-09 06:33:22 |
合計ジャッジ時間 | 5,752 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
5,764 KB |
testcase_01 | AC | 2 ms
5,400 KB |
testcase_02 | AC | 3 ms
5,900 KB |
testcase_03 | AC | 2 ms
5,464 KB |
testcase_04 | AC | 2 ms
5,444 KB |
testcase_05 | AC | 2 ms
5,420 KB |
testcase_06 | AC | 2 ms
5,396 KB |
testcase_07 | AC | 2 ms
5,436 KB |
testcase_08 | AC | 2 ms
5,464 KB |
testcase_09 | AC | 2 ms
5,592 KB |
testcase_10 | AC | 2 ms
5,416 KB |
testcase_11 | AC | 2 ms
5,612 KB |
testcase_12 | AC | 2 ms
5,468 KB |
testcase_13 | AC | 8 ms
6,428 KB |
testcase_14 | AC | 4 ms
6,752 KB |
testcase_15 | AC | 31 ms
10,972 KB |
testcase_16 | AC | 33 ms
10,116 KB |
testcase_17 | AC | 523 ms
44,172 KB |
testcase_18 | AC | 729 ms
26,848 KB |
testcase_19 | AC | 672 ms
116,264 KB |
testcase_20 | AC | 661 ms
21,116 KB |
testcase_21 | AC | 650 ms
76,032 KB |
ソースコード
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <cstdio> #include <queue> #include "math.h" #include <complex> #include <iomanip> #include <map> #define ifor(i,a,b) for (int i=(a);i<(b);i++) #define rfor(i,a,b) for (int i=(b)-1;i>=(a);i--) #define rep(i,n) for (int i=0;i<(n);i++) #define rrep(i,n) for (int i=(n)-1;i>=0;i--) using namespace std; typedef long double ld; typedef long long int lli; typedef pair<int,int> P; const double eps = 1e-11; int vex[4]={1,0,-1,0}; int vey[4]={0,1,0,-1}; typedef vector<double> Vec; typedef vector<int> vec; typedef vector<Vec> MAT; typedef vector<vec> mat; lli MOD=1000000007; int main(){ int H,W; cin >> H >> W; bool fi[3004][3004]; bool dis [3004][3004]; queue<pair<P,int> > que; rep(i,H+2){ rep(j,W+2){ if(j==W+1||j==0||i==0||i==H+1)que.push(make_pair(P(i,j),0)); } } char c; rep(i,H)rep(j,W){ cin>>c; if(c=='#')fi[i+1][j+1]=true; if(c=='.')que.push(make_pair(P(i+1,j+1),0)); } int ans = 0; while(!que.empty()){ P p= que.front().first; int d = que.front().second; ans = max(ans,que.front().second); que.pop(); for(int i = -1;i<=1;i++){ for(int j = -1;j<=1;j++){ if(p.first+i<0||p.second +j<0)continue; if(!(i==0&&j==0)&&!dis[p.first+i][p.second+j]&&fi[p.first+i][p.second+j]){ dis[p.first+i][p.second+j]=true; que.push(make_pair(P(i+p.first,j+p.second),d+1)); } } } } cout<<ans<<endl; }