結果

問題 No.430 文字列検索
ユーザー jjjj
提出日時 2016-10-02 23:40:23
言語 Fortran
(gFortran 13.2.0)
結果
WA  
実行時間 -
コード長 955 bytes
コンパイル時間 876 ms
コンパイル使用メモリ 32,896 KB
実行使用メモリ 7,212 KB
最終ジャッジ日時 2024-05-01 10:54:02
合計ジャッジ時間 8,392 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 571 ms
7,008 KB
testcase_02 AC 688 ms
7,020 KB
testcase_03 AC 628 ms
6,944 KB
testcase_04 WA -
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 8 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
権限があれば一括ダウンロードができます

ソースコード

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**(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**(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