結果
問題 |
No.402 最も海から遠い場所
|
ユーザー |
![]() |
提出日時 | 2016-07-22 23:52:20 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,149 bytes |
コンパイル時間 | 887 ms |
コンパイル使用メモリ | 72,536 KB |
実行使用メモリ | 51,232 KB |
最終ジャッジ日時 | 2024-11-06 13:29:57 |
合計ジャッジ時間 | 6,518 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 WA * 1 TLE * 1 -- * 4 |
ソースコード
#include<iostream> #include<algorithm> #include<stdio.h> #include<stdlib.h> #include<vector> #include<string> #include<sstream> using namespace std; int main(){ int h,w; cin >> h >> w; vector<string> s(h); for(int i=0;i<h;i++){ cin >> s[i]; } vector< vector<int> > a(h+2,vector<int>(w+2)); vector< vector<int> > b(h+2,vector<int>(w+2)); for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ if( s[i][j] == '#' ){ a[i+1][j+1] = 10000; }else{ a[i+1][j+1] = 0; } } } b=a; int dx[9] = {1,1, 1,0,0, 0,-1,-1,-1}; int dy[9] = {1,0,-1,1,0,-1, 1, 0,-1}; int cnt=1; while( cnt < max(h,w) ){ for(int x=0;x<h+2;x++){ for(int y=0;y<w+2;y++){ if( a[x][y] != 10000 ) continue; for(int i=0;i<9;i++){ if( a[x+dx[i]][y+dy[i]] == cnt-1 ){ b[x][y] = cnt; break; } } } } cnt++; a = b; } int ans=0; for(int i=1;i<h+1;i++){ for(int j=1;j<w+1;j++){ // printf("%d",a[i][j]); if(ans < a[i][j]) ans = a[i][j]; } // printf("\n"); } cout << ans << endl; return 0; }