結果

問題 No.402 最も海から遠い場所
ユーザー jjjj
提出日時 2016-07-23 04:56:22
言語 Fortran
(gFortran 13.2.0)
結果
TLE  
実行時間 -
コード長 2,087 bytes
コンパイル時間 328 ms
コンパイル使用メモリ 35,072 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-04-24 07:13:52
合計ジャッジ時間 5,519 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

subroutine create_map(map,H,W)
  implicit none
  logical,parameter::riku=.true.,umi=.false.
  character*3000::string
  integer(kind=4)::H,W,i,j
  logical,allocatable::map(:,:)

  read *,H,W

  allocate(map(0:W+1,0:H+1))

  do i=1,H
     read *, string
     do j=1,W
        if(string(j:j)=='.') then
           map(j,i)=umi
        else
           map(j,i)=riku
        end if
     end do
  end do
  map(0  ,:)  =umi
  map(W+1,:)  =umi
  map(:  ,0)  =umi
  map(:,H+1)  =umi

end subroutine create_map

integer function get_stream(map,H,W)
  integer(kind=4)::H,W,i,j,closest
  logical,parameter::riku=.true.,umi=.false.
  integer,allocatable::length(:)
  logical,allocatable::map(:,:)

  allocate(length(MAX(H,W)))

  length =0
  do i=1,W
     closest=0
     do j=1,H
        if(map(i,j).eqv.riku) then
           length(j)=j-closest
        else
           closest=j
        end if
     end do
  end do
  get_stream=MAXVAL(length)

  length =0
  do j=1,H
     closest=0
     do i=1,W
        if(map(i,j).eqv.riku) then
           length(i)=i-closest
        else
           closest=i
        end if
     end do
  end do
  get_stream=MIN(MAXVAL(length), get_stream)
end function get_stream

program main
  implicit none
  interface
     subroutine create_map(map,H,W)
       logical,allocatable::map(:,:)
       integer::H,W
     end subroutine create_map

     integer function get_stream(map,H,W)
       integer(kind=4)::H,W
       logical,allocatable::map(:,:)
     end function get_stream
  end interface
  integer(kind=4)::H,W
  logical,allocatable::map(:,:)
  logical,parameter::riku=.true.,umi=.false.
  integer,allocatable::dist_h(:),dist_w(:)
  integer::i,j,k,l,max_dist=1,dist,length

  call create_map(map,H,W)
  length = get_stream(map,H,W)-1

  do dist=length,0,-1
     do i=dist,W-dist+1
        do j=dist,H-dist+1
           if(map(i,j).eqv.riku) then
              if(ALL(ALL(map(i-dist:i+dist,j-dist:j+dist),1))) then
                 print '(i0)', dist+1
                 return
              end if
           end if
        end do
     end do
  end do
end program main
0