結果

問題 No.11 カードマッチ
ユーザー 37zigen37zigen
提出日時 2018-04-01 21:07:32
言語 Fortran
(gFortran 13.2.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,170 bytes
コンパイル時間 941 ms
コンパイル使用メモリ 27,208 KB
実行使用メモリ 4,636 KB
最終ジャッジ日時 2023-09-08 12:34:51
合計ジャッジ時間 2,136 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,540 KB
testcase_01 AC 2 ms
4,564 KB
testcase_02 AC 2 ms
4,604 KB
testcase_03 AC 1 ms
4,560 KB
testcase_04 AC 1 ms
4,572 KB
testcase_05 AC 1 ms
4,528 KB
testcase_06 AC 2 ms
4,636 KB
testcase_07 AC 2 ms
4,512 KB
testcase_08 AC 2 ms
4,560 KB
testcase_09 AC 1 ms
4,568 KB
testcase_10 AC 2 ms
4,572 KB
testcase_11 AC 2 ms
4,524 KB
testcase_12 AC 1 ms
4,524 KB
testcase_13 AC 2 ms
4,588 KB
testcase_14 AC 2 ms
4,524 KB
testcase_15 AC 2 ms
4,512 KB
testcase_16 AC 2 ms
4,632 KB
testcase_17 AC 2 ms
4,540 KB
testcase_18 AC 2 ms
4,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

recursive subroutine qsort(a,s,t)
      integer::a(*)
      integer::s,t
      integer::i,j,k,l,m,n
      
      if(t-s<=1)return
      
      i=s
      j=t-1
      
      m=a((s+t)/2)
      
      do
            do while(a(i)<m)
                  i=i+1
            end do
            do while(a(j)>m)
                  j=j-1
            end do
            if(i>=j)exit
            a(i)=xor(a(i),a(j))
            a(j)=xor(a(i),a(j))
            a(i)=xor(a(i),a(j))
            i=i+1
            j=j-1
      end do
      
      call qsort(a,s,i)
      call qsort(a,j+1,t)
end subroutine qsort


program main
      implicit none
      integer::i,j,k,l,m,cnt1=0,cnt2=0,N,W,H,a(1000000),b(1000000)
      integer::ans
      read*,W
      read*,H
      read*,N
      do i=1,N
            read(*,*)a(i),b(i)
      end do
      
      call qsort(a,1,N+1)
      call qsort(b,1,N+1)
      
      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