結果

問題 No.429 CupShuffle
ユーザー jjjj
提出日時 2016-10-02 22:56:24
言語 Fortran
(gFortran 13.2.0)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 862 bytes
コンパイル時間 737 ms
コンパイル使用メモリ 28,988 KB
実行使用メモリ 4,688 KB
最終ジャッジ日時 2023-08-13 17:16:26
合計ジャッジ時間 1,291 ms
ジャッジサーバーID
(参考情報)
judge13 / judge10
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 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 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 8 ms
4,380 KB
testcase_11 AC 72 ms
4,688 KB
testcase_12 AC 69 ms
4,552 KB
testcase_13 AC 72 ms
4,552 KB
testcase_14 AC 71 ms
4,556 KB
testcase_15 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

program main
  implicit none
  integer::N,K,X,i,tmp
  character::q(2)
  integer,allocatable::A(:),B(:),C(:),cupi(:),cupf(:)
  logical::is_first=.true.
  read *,N,K,X
  allocate(A(K),B(K),C(N),cupi(N),cupf(N))

  do i=1,K
     if(i.eq.X) then
        read *,q
     else
        read *, A(i),B(i)
     end if
  end do
  cupi = (/(i,i=1,N)/)
  read *,cupf

! swap forward
  do i=1,X-1
     tmp = cupi(A(i))
     cupi(A(i)) = cupi(B(i))
     cupi(B(i)) = tmp
  end do
! swap backward
  do i=K,X+1,-1
     tmp = cupf(A(i))
     cupf(A(i)) = cupf(B(i))
     cupf(B(i)) = tmp
  end do
  do i=1,N
     if(cupi(i).ne.cupf(i))then
        if(is_first.eqv..true.) then
           is_first = .false.
           write (*,'(i0," ")',advance='no') i
        else
           write (*,'(i0)',advance='yes') i
           return
        end if
     end if
  end do
end program main
0