結果

問題 No.228 ゆきこちゃんの 15 パズル
ユーザー jjjj
提出日時 2017-01-08 05:43:08
言語 Fortran
(gFortran 13.2.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,157 bytes
コンパイル時間 1,600 ms
コンパイル使用メモリ 27,056 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-22 17:31:13
合計ジャッジ時間 3,373 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

program main
  implicit none
  integer::p(0:5,0:5)
  integer::i,x,y,move
  data p/36*-1/

  do i=1,4
     read *,p(i,1:4)
  end do
! find zero
  do x=1,4
     do y=1,4
        if(p(x,y).eq.0) then
           goto 10
        end if
     end do
  end do
10 continue

! move
  do
     move = MOD((x-1)*4+y,16)
!     print *, x,y,move
!     call printer(p)
     if(p(x-1,y).eq.move) then
        p(x,y) = move
        p(x-1,y) = 0
        x = x-1
     else if(p(x+1,y).eq.move) then
        p(x,y) = move
        p(x+1,y) = 0
        x = x+1
     else if(p(x,y-1).eq.move) then
        p(x,y) = move
        p(x,y-1) = 0
        y = y-1
     else if(p(x,y+1).eq.move) then
        p(x,y) = move
        p(x,y+1) = 0
        y = y+1
     else
        exit
     end if
  end do

! check
  do x=1,4
     do y=1,4
        if(p(x,y).eq.MOD((x-1)*4+y,16)) then
           continue
        else
           print '(a)',"No"
           return
        end if
     end do
  end do
  print '(a)',"Yes"
  return
contains
  subroutine printer(p)
    integer::p(0:5,0:5)
    integer::x
    do x=1,4
       print *,p(x,1:4)
    end do
  end subroutine printer
end program main
0