結果

問題 No.402 最も海から遠い場所
ユーザー jjjj
提出日時 2016-07-22 23:57:02
言語 Fortran
(gFortran 13.2.0)
結果
WA  
実行時間 -
コード長 1,202 bytes
コンパイル時間 1,482 ms
コンパイル使用メモリ 35,448 KB
実行使用メモリ 51,712 KB
最終ジャッジ日時 2024-04-24 06:23:27
合計ジャッジ時間 6,319 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

  integer(kind=2)::H,W
  character,allocatable::map(:,:)
  character,parameter::riku='#',umi='.'
  logical,allocatable::covered(:,:)
  character*3000::string
  integer::cdist

  read *,H,W
  allocate(map(0:W+1,0:H+1))
  allocate(covered(0:W+1,0:H+1))

  do i=1,H
     read *, string
     do j=1,W
        map(i,j)=string(j:j)
     end do
  end do

  map(0  ,:)  =umi
  map(W+1,:)  =umi
  map(:  ,0)  =umi
  map(:,H+1)  =umi

  do i=0,H+1
     do j=0,W+1
        if (map(i,j).eq.umi) then
           covered(i,j)=.true.
        else
           covered(i,j)=.false.
        end if
     end do
  end do

!  check cover all riku in cdist
  do cdist=1, MAX(H,W)
     do i=0,W+1
        do j=0,H+1
           if (map(i,j).eq.umi) then
              covered(MIN(i+cdist,W+1),MAX(0,j-cdist):MIN(j+cdist,H+1))=.true.
              covered(MAX(i-cdist,0),  MAX(0,j-cdist):MIN(j+cdist,H+1))=.true.
              covered(MAX(0,i-cdist):MIN(i+cdist,W+1),MIN(j+cdist,H+1))=.true.
              covered(MAX(0,i-cdist):MIN(i+cdist,W+1),MAX(j-cdist,0))  =.true.
           endif
        end do
     end do
     if ( ALL(covered).eqv..true.) then
        print '(i0)',cdist
        exit
     end if
  end do
end program
0