結果

問題 No.402 最も海から遠い場所
ユーザー itezpaceitezpace
提出日時 2016-10-03 10:35:29
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,219 bytes
コンパイル時間 772 ms
コンパイル使用メモリ 67,344 KB
実行使用メモリ 38,528 KB
最終ジャッジ日時 2024-05-01 11:14:09
合計ジャッジ時間 5,163 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 WA -
testcase_19 AC 228 ms
38,528 KB
testcase_20 AC 245 ms
38,528 KB
testcase_21 AC 231 ms
38,528 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
  int H,W;cin>>H>>W;
  string S;
  vector<vector<int>> vv(H+2,vector<int>(W+2,-1));
  for(int i=0;i<H+2;++i) vv[i][0]=0;
  for(int i=0;i<H+2;++i) vv[i][W+2-1]=0;
  for(int i=0;i<W+2;++i) vv[0][i]=0;
  for(int i=0;i<W+2;++i) vv[H+2-1][i]=0;

  for(int i=0;i<H;++i){
    cin>>S;
    for(int j=0;j<W;++j){
      if(S[j]=='.'){
        vv[i+1][j+1]=0;
      } else {
        int a=vv[i+1][j];
        int b=vv[i][j];
        int c=vv[i][j+1];
        vv[i+1][j+1]=min(min(a,b),c)+1;
      }
    }
  }

  for(int i=1;i<=H;++i){
    for(int j=W;j>=1;--j){
      int a=vv[i][j];
      int b=vv[i][j+1];
      int c=vv[i-1][j+1];
      vv[i][j]=min(a,min(b,c)+1);
    }
  }

  for(int i=1;i<=W;++i){
    for(int j=H;j>=1;--j){
      int a=vv[i][j];
      int b=vv[i+1][j-1];
      int c=vv[i+1][j];
      vv[i][j]=min(a,min(b,c)+1);
    }
  }

  for(int i=1;i<=W;++i){
    for(int j=H;j>=1;--j){
      int a=vv[i][j];
      int b=vv[i+1][j+1];
      vv[i][j]=min(a,b+1);
    }
  }

  int ans=0;
  for(int i=1;i<H+2;++i){
    for(int j=1;j<W+2;++j){
      if(vv[i][j]>ans) ans=vv[i][j];
    }
  }
  cout<<ans<<endl;
}
0