結果

問題 No.355 数当てゲーム(2)
ユーザー jjjj
提出日時 2017-01-08 06:35:04
言語 Fortran
(gFortran 13.2.0)
結果
RE  
実行時間 -
コード長 1,367 bytes
コンパイル時間 837 ms
コンパイル使用メモリ 27,312 KB
実行使用メモリ 24,432 KB
平均クエリ数 49.25
最終ジャッジ日時 2023-09-23 12:34:56
合計ジャッジ時間 7,951 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 24 ms
23,856 KB
testcase_02 RE -
testcase_03 AC 23 ms
24,420 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 25 ms
24,288 KB
testcase_07 AC 23 ms
23,448 KB
testcase_08 AC 23 ms
23,556 KB
testcase_09 AC 25 ms
23,388 KB
testcase_10 AC 23 ms
24,072 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 25 ms
24,192 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 AC 23 ms
23,436 KB
testcase_20 AC 23 ms
23,964 KB
testcase_21 AC 25 ms
23,592 KB
testcase_22 RE -
testcase_23 RE -
testcase_24 AC 24 ms
23,748 KB
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 AC 22 ms
24,384 KB
testcase_29 RE -
testcase_30 AC 23 ms
24,072 KB
testcase_31 RE -
testcase_32 AC 24 ms
23,472 KB
testcase_33 AC 22 ms
24,192 KB
testcase_34 AC 23 ms
23,856 KB
testcase_35 AC 24 ms
23,592 KB
testcase_36 RE -
testcase_37 AC 24 ms
24,264 KB
testcase_38 AC 25 ms
24,072 KB
testcase_39 AC 25 ms
23,664 KB
testcase_40 AC 24 ms
24,408 KB
testcase_41 AC 25 ms
23,964 KB
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
testcase_46 RE -
testcase_47 RE -
testcase_48 AC 23 ms
23,952 KB
testcase_49 RE -
testcase_50 AC 24 ms
23,952 KB
testcase_51 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

program main
  implicit none
  integer::n(1:4),m(1:4)
  integer::hit,blow,phit,pblow,i,j
  data n/0,1,2,3/

  call get(n,hit,blow)
  if(hit.eq.4) return

! selection
  if(hit+blow.ne.4) then
     do i=1,4
        phit = hit
        pblow = blow
        m = n
        do j=0,9
           if(ANY(n.eq.j)) cycle
           m(i) = j
           call get(m,hit,blow)
           if(hit+blow.eq.4) then
              n = m
              goto 10
           else if(hit+blow.gt.phit+pblow) then
              n = m
              exit
           end if
        end do
     end do
  end if
10 continue
  ! shuffle
  do
     call next_permutation(n)
     call get(n,hit,blow)
     if(hit.eq.4) then
        return
     end if
  end do
contains
  subroutine get(n,hit,blow)
    integer::n(1:4)
    integer::hit,blow
    print '(i0," ",i0," ",i0," ",i0)',n
    read *,hit,blow
  end subroutine get
  subroutine next_permutation(array)
    implicit none
    integer::array(:),d,i,j,k,swap
    d = 4

    do i=d,2,-1
       if(array(i-1).lt.array(i)) exit
    end do
    do j=d,i+1,-1
       if(array(i-1).lt.array(j)) exit
    end do

    swap       = array(i-1)
    array(i-1) = array(j)
    array(j)   = swap
    do k=0, (d-1-i)/2
       swap       = array(i+k)
       array(i+k) = array(d-k)
       array(d-k) = swap
    end do
  end subroutine next_permutation

end program main
0