結果

問題 No.11 カードマッチ
ユーザー 37zigen
提出日時 2018-04-08 20:09:05
言語 Fortran
(gFortran 14.2.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 876 bytes
コンパイル時間 1,714 ms
コンパイル使用メモリ 35,200 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-26 20:24:41
合計ジャッジ時間 2,314 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

module mdl
contains
    recursive function qsort(a)result(res)
        implicit none
        integer,intent(in)::a(:)
        integer::res(size(a))
        if(size(a)<=1)then
            res=a
            return
        end if
        res=[qsort(pack(a(2:),a(2:)<a(1))),a(1),qsort(pack(a(2:),a(2:)>=a(1)))]
    end function qsort
end module


program main
    use mdl
    implicit none
    integer::i,j,k,l,m,cnt1=0,cnt2=0,N,W,H
    integer,allocatable::a(:),b(:)
    integer::ans
    read*,W
    read*,H
    read*,N
    allocate(a(N))
    allocate(b(N))
    do i=1,N
        read(*,*)a(i),b(i)
    end do

    a=qsort(a)
    b=qsort(b)

    do i=1,N
        if(i+1<=N.and.a(i)==a(i+1))cycle
        cnt1=cnt1+1
    end do

    do i=1,N
        if(i+1<=N.and.b(i)==b(i+1))cycle
        cnt2=cnt2+1
    end do

    ans=H*W-(W-cnt1)*(H-cnt2)-N
    print*,ans


end program main
0