結果
問題 | No.424 立体迷路 |
ユーザー |
![]() |
提出日時 | 2016-09-22 22:56:57 |
言語 | Fortran (gFortran 14.2.0) |
結果 |
AC
|
実行時間 | 40 ms / 2,000 ms |
コード長 | 1,438 bytes |
コンパイル時間 | 1,433 ms |
コンパイル使用メモリ | 36,808 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-05 07:05:05 |
合計ジャッジ時間 | 2,131 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 21 |
ソースコード
program mainimplicit noneinteger::h,w,sx,sy,gx,gycharacter*50::inputinteger,allocatable::height(:,:)integer,allocatable::reach(:,:)integer::i,j,itr,nexti,nextjread *, h,wread *, sx,sy,gx,gyallocate(height(-1:h+2,-1:w+2),reach(h,w))do i=1,hread *,inputdo j=1,LEN_TRIM(input)height(i,j) = ICHAR(input(j:j))-ICHAR('0')end doend doheight(-1:0 ,:) = 100height(h+1:h+2,:) = 100height(: ,-1:0) = 100height(: ,w+1:w+2) = 100reach = 0reach(sx,sy) = 1do itr=1,h*wdo i=1,hdo j=1,wif(reach(i,j).ne.1) cycleif(abs(height(i,j)-height(i,j+1)).le.1) reach(i,j+1) = 1if(abs(height(i,j)-height(i,j-1)).le.1) reach(i,j-1) = 1if(abs(height(i,j)-height(i+1,j)).le.1) reach(i+1,j) = 1if(abs(height(i,j)-height(i-1,j)).le.1) reach(i-1,j) = 1if(height(i,j).eq.height(i,j+2).and.height(i,j).gt.height(i,j+1)) reach(i,j+2) = 1if(height(i,j).eq.height(i,j-2).and.height(i,j).gt.height(i,j-1)) reach(i,j-2) = 1if(height(i,j).eq.height(i+2,j).and.height(i,j).gt.height(i+1,j)) reach(i+2,j) = 1if(height(i,j).eq.height(i-2,j).and.height(i,j).gt.height(i-1,j)) reach(i-2,j) = 1end doend doif(reach(gx,gy).eq.1) thenprint '(a)',"YES"returnend ifend doprint '(a)',"NO"end program main