結果
| 問題 | No.430 文字列検索 | 
| コンテスト | |
| ユーザー |  jj | 
| 提出日時 | 2016-10-02 23:40:23 | 
| 言語 | Fortran (gFortran 14.2.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 955 bytes | 
| コンパイル時間 | 145 ms | 
| コンパイル使用メモリ | 33,280 KB | 
| 実行使用メモリ | 7,160 KB | 
| 最終ジャッジ日時 | 2024-11-10 00:04:31 | 
| 合計ジャッジ時間 | 7,112 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 WA * 1 | 
| other | AC * 7 WA * 7 | 
ソースコード
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
            
            
            
        