結果
| 問題 |
No.430 文字列検索
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-05-11 01:11:07 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,076 bytes |
| コンパイル時間 | 217 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 78,848 KB |
| 最終ジャッジ日時 | 2024-11-10 01:00:27 |
| 合計ジャッジ時間 | 3,549 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 4 |
| other | AC * 1 TLE * 1 -- * 12 |
ソースコード
import math
import sys
import heapq
from collections import deque
sys.setrecursionlimit(500*500)
stdin = sys.stdin
def YES(): print('Yes')
def NO(): print('No')
def TAKAHASHI(): print('Takahashi')
def AOKI(): print("Aoki")
def ns(): return stdin.readline().strip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))
def nz(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def nm(n): return [na() for _ in range(n)]
MOD = int(1e9+7)
def YES():
print('Yes')
def NO():
print('No')
def TAKAHASHI():
print('Takahashi')
def AOKI():
print("Aoki")
s = ns()
M = ni()
s_set = [set()]*11
ans = 0
ord_a = ord('A')
def o(s):
return ord(s)-ord_a
for i in range(M):
c = ns()
lc = len(c)
hc = 0
hs = 0
for l in range(lc):
hc += o(c[l])*26**l
hs += o(s[l])*26**l
if hc == hs:
ans += 1
for j in range(1, len(s)-lc+1):
hs -= o(s[j-1])
hs //= 26
hs += o(s[j+lc-1])*26**(lc-1)
if hs == hc:
ans += 1
print(ans)