結果

問題 No.402 最も海から遠い場所
ユーザー Yut176Yut176
提出日時 2016-07-23 00:09:50
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,800 bytes
コンパイル時間 622 ms
コンパイル使用メモリ 68,644 KB
実行使用メモリ 92,320 KB
最終ジャッジ日時 2024-04-24 06:39:18
合計ジャッジ時間 6,590 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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] = 1;
      }else{
        a[i+1][j+1] = 0;
      }
    }
  }

  int ans = -1;
  for(int i=1;i<h+1;i++){
    for(int j=1;j<w+1;j++){
      if( a[i][j] == 0 ) continue;

      int dx[4] = {1,0, 0,-1};
      int dy[4] = {0,1,-1, 0};
      int tmp=10000;
      for(int k=0;k<4;k++){
        int mx = i + dx[k];
        int my = i + dy[k];
        int cnt = 0;
        while( true ){
          if( a[mx][my] == 0 ) break;
          mx += dx[k];
          my += dy[k];
          cnt++;
        }
        if( tmp > cnt ) tmp = cnt;
      }
      if( ans < tmp ) ans = tmp;
    }
  }
  cout << ans << endl;

  // b=a;
  //
  // int dx[9] = {1,1, 1,0, 0,-1,-1,-1};
  // int dy[9] = {1,0,-1,1,-1, 1, 0,-1};
  // int cnt=1;
  //
  // while( cnt < max(h+2,w+2)/2 ){
  //
  //   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<8;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;
}
0