結果
問題 | No.402 最も海から遠い場所 |
ユーザー | latte0119 |
提出日時 | 2016-07-22 22:35:41 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 598 ms / 3,000 ms |
コード長 | 1,502 bytes |
コンパイル時間 | 1,228 ms |
コンパイル使用メモリ | 153,044 KB |
実行使用メモリ | 239,412 KB |
最終ジャッジ日時 | 2023-08-06 09:45:03 |
合計ジャッジ時間 | 4,849 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 20 ms
74,236 KB |
testcase_01 | AC | 20 ms
74,272 KB |
testcase_02 | AC | 21 ms
74,368 KB |
testcase_03 | AC | 20 ms
74,340 KB |
testcase_04 | AC | 20 ms
74,236 KB |
testcase_05 | AC | 20 ms
74,296 KB |
testcase_06 | AC | 20 ms
74,212 KB |
testcase_07 | AC | 20 ms
74,236 KB |
testcase_08 | AC | 21 ms
74,212 KB |
testcase_09 | AC | 21 ms
74,480 KB |
testcase_10 | AC | 21 ms
74,480 KB |
testcase_11 | AC | 20 ms
74,388 KB |
testcase_12 | AC | 20 ms
74,224 KB |
testcase_13 | AC | 22 ms
74,692 KB |
testcase_14 | AC | 21 ms
74,620 KB |
testcase_15 | AC | 31 ms
76,696 KB |
testcase_16 | AC | 36 ms
77,772 KB |
testcase_17 | AC | 224 ms
118,544 KB |
testcase_18 | AC | 598 ms
99,748 KB |
testcase_19 | AC | 395 ms
239,412 KB |
testcase_20 | AC | 325 ms
92,240 KB |
testcase_21 | AC | 331 ms
166,104 KB |
ソースコード
#include<bits/stdc++.h> using namespace std; #define int long long typedef vector<int>vint; typedef pair<int,int>pint; typedef vector<pint>vpint; #define rep(i,n) for(int i=0;i<(n);i++) #define reps(i,f,n) for(int i=(f);i<(n);i++) #define all(v) (v).begin(),(v).end() #define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++) #define pb push_back #define mp make_pair #define fi first #define se second template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;} template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;} int H,W; string fld[3010]; int dist[3010][3010]; signed main(){ cin.tie(0); ios_base::sync_with_stdio(false); cin>>H>>W; for(int i=1;i<=H;i++){ cin>>fld[i]; fld[i]="."+fld[i]+"."; } fld[0]=fld[H+1]=string(W+2,'.'); H+=2;W+=2; memset(dist,-1,sizeof(dist)); queue<pint>que; rep(i,H)rep(j,W){ if(fld[i][j]=='.'){ dist[i][j]=0; que.push(pint(i,j)); } } while(que.size()){ int y,x; tie(y,x)=que.front(); que.pop(); for(int dy=-1;dy<=1;dy++){ for(int dx=-1;dx<=1;dx++){ int ny=y+dy,nx=x+dx; if(ny<0||ny>=H||nx<0||nx>=W||dist[ny][nx]!=-1)continue; dist[ny][nx]=dist[y][x]+1; que.push(pint(ny,nx)); } } } int ma=0; rep(i,H)rep(j,W)chmax(ma,dist[i][j]); cout<<ma<<endl; return 0; }