結果

問題 No.430 文字列検索
ユーザー jjjj
提出日時 2016-10-02 23:42:11
言語 Fortran
(gFortran 13.2.0)
結果
AC  
実行時間 709 ms / 2,000 ms
コード長 962 bytes
コンパイル時間 1,130 ms
コンパイル使用メモリ 27,760 KB
実行使用メモリ 7,276 KB
最終ジャッジ日時 2023-08-15 17:27:59
合計ジャッジ時間 8,515 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,720 KB
testcase_01 AC 614 ms
7,200 KB
testcase_02 AC 608 ms
7,164 KB
testcase_03 AC 697 ms
7,168 KB
testcase_04 AC 2 ms
4,852 KB
testcase_05 AC 2 ms
4,704 KB
testcase_06 AC 2 ms
4,700 KB
testcase_07 AC 1 ms
4,680 KB
testcase_08 AC 10 ms
7,020 KB
testcase_09 AC 2 ms
4,768 KB
testcase_10 AC 3 ms
5,036 KB
testcase_11 AC 665 ms
7,232 KB
testcase_12 AC 634 ms
7,228 KB
testcase_13 AC 660 ms
7,188 KB
testcase_14 AC 709 ms
7,272 KB
testcase_15 AC 627 ms
7,276 KB
testcase_16 AC 609 ms
7,196 KB
testcase_17 AC 629 ms
7,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

program main
  implicit none
  character*50000::S
  character*10::c(5000)
  integer*8::snum(50000)
  integer*8::shash(10,50000)
  integer*8::chash(5000)
  integer::clen(5000)
  integer::M,i,j,slen
  integer*8::match=0,tmp
  read *,S
  read *,M
  read *,c(1:M)
  clen(1:M) = LEN_TRIM(c(1:M))
  slen = LEN_TRIM(S)
  do i=1,slen
     snum(i) = ICHAR(S(i:i))-ICHAR('A') + 1
  end do
  do i=1,slen
     tmp = 1
     do j=1,10
        if(i+j-1.gt.slen) exit
        tmp = tmp + snum(i+j-1) * 26_8**(j-1)
        shash(j,i) = tmp
     end do
  end do
  do i=1,M
     tmp = 1
     do j=1,clen(i)
        tmp = tmp + (ICHAR(c(i)(j:j))-ICHAR('A') + 1) * 26_8**(j-1)
     end do
     chash(i) = tmp
  end do
  do j=1,M
     tmp = clen(j)
!     print '(a,i0)',"chash:",chash(j)
!     print *,shash(tmp,1:slen)
     do i=1,slen
        if(shash(tmp,i).eq.chash(j)) then
           match = match + 1
        end if
     end do
  end do

  print '(i0)',match

end program main
0