結果
問題 |
No.402 最も海から遠い場所
|
ユーザー |
![]() |
提出日時 | 2016-07-23 01:29:48 |
言語 | Fortran (gFortran 14.2.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,391 bytes |
コンパイル時間 | 654 ms |
コンパイル使用メモリ | 37,320 KB |
実行使用メモリ | 52,808 KB |
最終ジャッジ日時 | 2024-11-06 14:16:30 |
合計ジャッジ時間 | 6,010 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 WA * 1 RE * 2 TLE * 1 -- * 3 |
ソースコード
integer(kind=4)::H,W character,allocatable::map(:,:) character,parameter::riku='#',umi='.' integer,allocatable::rcdist(:,:) character*3000::string integer::cdist,min_cdist,max_cdist read *,H,W allocate(map(0:W+1,0:H+1)) allocate(rcdist(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 if(H.eq.1.and.W.eq.1) then print '(a)',"1" return endif map(0,:) =umi map(W+1,:)=umi map(:,0) =umi map(:,H+1)=umi rcdist=0 do i=0,H+1 do j=0,W+1 if (map(i,j).eq.umi) then if(map(i+1,j+1).eq.riku) rcdist(i+1,j+1)=1 if(map(i+1,j-1).eq.riku) rcdist(i+1,j-1)=1 if(map(i+1,j ).eq.riku) rcdist(i+1,j )=1 if(map(i-1,j+1).eq.riku) rcdist(i-1,j+1)=1 if(map(i-1,j-1).eq.riku) rcdist(i-1,j-1)=1 if(map(i-1,j ).eq.riku) rcdist(i-1,j )=1 if(map(i ,j+1).eq.riku) rcdist(i ,j+1)=1 if(map(i ,j-1).eq.riku) rcdist(i ,j-1)=1 end if end do end do ! propagation do l=2,MAX(H,W) do i=1,W do j=1,H if (map(i,j).eq.riku .and. rcdist(i,j).eq.l-1) then if(map(i+1,j+1).eq.riku .and. rcdist(i+1,j+1).eq.0) rcdist(i+1,j+1)=l if(map(i+1,j-1).eq.riku .and. rcdist(i+1,j-1).eq.0) rcdist(i+1,j-1)=l if(map(i+1,j ).eq.riku .and. rcdist(i+1,j ).eq.0) rcdist(i+1,j )=l if(map(i-1,j+1).eq.riku .and. rcdist(i-1,j+1).eq.0) rcdist(i-1,j+1)=l if(map(i-1,j-1).eq.riku .and. rcdist(i-1,j-1).eq.0) rcdist(i-1,j-1)=l if(map(i-1,j ).eq.riku .and. rcdist(i-1,j ).eq.0) rcdist(i-1,j )=l if(map(i ,j+1).eq.riku .and. rcdist(i ,j+1).eq.0) rcdist(i ,j+1)=l if(map(i ,j-1).eq.riku .and. rcdist(i ,j-1).eq.0) rcdist(i ,j-1)=l endif end do end do min_cdist=1 max_cdist=0 do i=1,W do j=1,H if(map(i,j).eq.riku .and. rcdist(i,j).eq.0) then goto 100 end if end do end do do i=1,W do j=1,H if(map(i,j).eq.riku) then min_cdist=MIN(min_cdist, rcdist(i,j)) max_cdist=MAX(max_cdist, rcdist(i,j)) end if end do end do print '(i0)',max_cdist exit 100 continue end do end program