結果
問題 | No.430 文字列検索 |
ユーザー | DrDrpilot |
提出日時 | 2023-01-12 16:28:44 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 872 ms / 2,000 ms |
コード長 | 1,264 bytes |
コンパイル時間 | 246 ms |
コンパイル使用メモリ | 10,852 KB |
実行使用メモリ | 42,940 KB |
最終ジャッジ日時 | 2023-08-24 23:03:58 |
合計ジャッジ時間 | 10,061 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 31 ms
10,048 KB |
testcase_01 | AC | 872 ms
42,940 KB |
testcase_02 | AC | 643 ms
12,524 KB |
testcase_03 | AC | 655 ms
12,488 KB |
testcase_04 | AC | 32 ms
9,936 KB |
testcase_05 | AC | 31 ms
9,972 KB |
testcase_06 | AC | 31 ms
9,920 KB |
testcase_07 | AC | 32 ms
9,952 KB |
testcase_08 | AC | 843 ms
42,644 KB |
testcase_09 | AC | 33 ms
9,900 KB |
testcase_10 | AC | 97 ms
12,580 KB |
testcase_11 | AC | 711 ms
16,508 KB |
testcase_12 | AC | 721 ms
16,576 KB |
testcase_13 | AC | 719 ms
16,576 KB |
testcase_14 | AC | 704 ms
14,308 KB |
testcase_15 | AC | 689 ms
14,160 KB |
testcase_16 | AC | 673 ms
12,400 KB |
testcase_17 | AC | 661 ms
12,352 KB |
ソースコード
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)