結果

問題 No.430 文字列検索
ユーザー DrDrpilotDrDrpilot
提出日時 2023-01-12 17:18:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 381 ms / 2,000 ms
コード長 1,264 bytes
コンパイル時間 452 ms
コンパイル使用メモリ 87,080 KB
実行使用メモリ 124,304 KB
最終ジャッジ日時 2023-08-24 23:35:11
合計ジャッジ時間 5,967 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 179 ms
81,664 KB
testcase_01 AC 381 ms
124,304 KB
testcase_02 AC 255 ms
86,980 KB
testcase_03 AC 257 ms
86,888 KB
testcase_04 AC 179 ms
81,784 KB
testcase_05 AC 178 ms
81,692 KB
testcase_06 AC 180 ms
81,832 KB
testcase_07 AC 181 ms
81,528 KB
testcase_08 AC 346 ms
123,796 KB
testcase_09 AC 187 ms
82,536 KB
testcase_10 AC 198 ms
83,196 KB
testcase_11 AC 292 ms
92,944 KB
testcase_12 AC 297 ms
92,720 KB
testcase_13 AC 293 ms
92,492 KB
testcase_14 AC 280 ms
88,864 KB
testcase_15 AC 277 ms
87,448 KB
testcase_16 AC 263 ms
86,948 KB
testcase_17 AC 267 ms
87,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def I():return int(input())
def MAP():return map(int,input().split())
def MAPs():return map(str,input().split())
def LI(): return list(map(int,input().split()))
def TPL(): return tuple(map(int,input().split()))
def S():return input()
from collections import defaultdict,Counter,deque
from copy import deepcopy
from heapq import heapify,heappop,heappush
from bisect import bisect_left,bisect_right
from itertools import accumulate,product,permutations,combinations,combinations_with_replacement
from math import gcd,ceil,floor,factorial,sqrt,pi,sin,cos,tan,radians,exp
from functools import lru_cache
import time
import random
import string
alp=string.ascii_lowercase;ALP=string.ascii_uppercase
inf=float('inf');mod=998244353;Mod=10**9+7
dydx=[(1,0),(0,1),(-1,0),(0,-1)]

s=S()
n=len(s)
m=I()
hash=[0]
for i in range(n):
    hash.append((hash[-1]*100+ALP.index(s[i])+1)%mod)
d=[defaultdict(int) for _ in range(11)]
for l in range(1,n+1):
    for length in range(10):
        if l+length>n:
            break
        r=l+length
        h=(hash[r]-hash[l-1]*pow(100,r-l+1,mod))%mod
        d[r-l+1][h]+=1
ans=0
for _ in range(m):
    c=S()
    num=0
    for i in range(len(c)):
        num=num*100+ALP.index(c[i])+1
        num%=mod
    ans+=d[len(c)][num]
print(ans)
0